feat: skift flowets vogn i guiden — tøm, sæt af og hent ny ved start (v1.62.44)
This commit is contained in:
@@ -367,18 +367,23 @@ local function rowsWait(guide)
|
||||
end
|
||||
|
||||
-- Vognvalg under en valgt solo-traktor: dens egen vogn + ledige vogne ingen anden traktor i flowet har.
|
||||
local function rowWagon(guide, tractorId)
|
||||
local function rowWagon(guide, tractorId, ownWagon)
|
||||
local wagons = guide.draft.wagons or {}
|
||||
local usedByOthers = {}
|
||||
for otherId, wagonId in pairs(wagons) do
|
||||
if otherId ~= tractorId then usedByOthers[wagonId] = true end
|
||||
end
|
||||
local options = {}
|
||||
-- vognen der hænger på traktoren nu står først (vælg en anden for at bytte ved næste start)
|
||||
if ownWagon ~= nil and ownWagon.id ~= nil then table.insert(options, {label = T(tostring(ownWagon.label)), value = ownWagon.id}) end
|
||||
for _, wagon in ipairs(guide.context.wagons or {}) do
|
||||
if not usedByOthers[wagon.id] then table.insert(options, {label = T(tostring(wagon.label)), value = wagon.id}) end
|
||||
if not usedByOthers[wagon.id] and (ownWagon == nil or wagon.id ~= ownWagon.id) then
|
||||
table.insert(options, {label = T(tostring(wagon.label)), value = wagon.id})
|
||||
end
|
||||
end
|
||||
if #options == 0 or wagons[tractorId] == nil then return text("spu_guide_flow_noFreeWagon") end
|
||||
return choice("wagon", L("spu_guide_flow_wagon"), options, wagons[tractorId], tractorId)
|
||||
local current = wagons[tractorId] or (ownWagon ~= nil and ownWagon.id or nil)
|
||||
if #options == 0 or current == nil then return text("spu_guide_flow_noFreeWagon") end
|
||||
return choice("wagon", L("spu_guide_flow_wagon"), options, current, tractorId)
|
||||
end
|
||||
|
||||
-- Traktorer: flowets egne først, så de ledige. Traktorer i andre flows og blokerede (vognen passer ikke)
|
||||
@@ -401,13 +406,15 @@ local function rowsTractors(guide)
|
||||
blocked = blocked + 1
|
||||
table.insert(blockedTexts, tostring(vehicle.text))
|
||||
end
|
||||
table.insert(entries, {id = vehicle.id, label = tostring(vehicle.text), state = state})
|
||||
table.insert(entries, {id = vehicle.id, label = tostring(vehicle.text), state = state, ownWagon = vehicle.ownWagon})
|
||||
end
|
||||
local solo = soloIds(guide.context)
|
||||
for _, entry in ipairs(ADFlowView.vehicleRows(entries, false)) do
|
||||
table.insert(rows, check("vehicleIds", entry.id, entry.label, entry.state == "in"))
|
||||
if entry.state == "in" and solo[entry.id] then
|
||||
local wagonRow = rowWagon(guide, entry.id)
|
||||
local own = nil
|
||||
for _, e in ipairs(entries) do if e.id == entry.id then own = e.ownWagon end end
|
||||
if entry.state == "in" and (solo[entry.id] or own ~= nil) then
|
||||
local wagonRow = rowWagon(guide, entry.id, own)
|
||||
if wagonRow ~= nil then table.insert(rows, wagonRow) end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user