feat(kæde): flows kan tilhøre en kæde
This commit is contained in:
@@ -69,7 +69,7 @@ end
|
|||||||
local RUN_FIELDS = {
|
local RUN_FIELDS = {
|
||||||
"id", "name", "kind", "sourceBuildingIds", "targetBuildingIds", "storeBuildingIds", "products",
|
"id", "name", "kind", "sourceBuildingIds", "targetBuildingIds", "storeBuildingIds", "products",
|
||||||
"ingredientMode", "ingredients", "sellAtPercent", "storeAbovePercent", "sellAbovePercent", "collectRound", "loops",
|
"ingredientMode", "ingredients", "sellAtPercent", "storeAbovePercent", "sellAbovePercent", "collectRound", "loops",
|
||||||
"returnBelowPercent", "waitPoolGroup", "vehicleIds", "wagons",
|
"returnBelowPercent", "waitPoolGroup", "vehicleIds", "wagons", "chain",
|
||||||
}
|
}
|
||||||
|
|
||||||
local function draftFrom(run, isNew)
|
local function draftFrom(run, isNew)
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ local function copyRun(run)
|
|||||||
vehicleIds = copyList(run.vehicleIds),
|
vehicleIds = copyList(run.vehicleIds),
|
||||||
stopped = run.stopped == true,
|
stopped = run.stopped == true,
|
||||||
wagons = ADRuns.copyWagons(run.wagons),
|
wagons = ADRuns.copyWagons(run.wagons),
|
||||||
|
chain = run.chain or "",
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -145,6 +146,7 @@ function ADRuns.createRun(store, name, kind)
|
|||||||
loops = 0,
|
loops = 0,
|
||||||
returnBelowPercent = ADRuns.DEFAULT_RETURN_BELOW_PERCENT,
|
returnBelowPercent = ADRuns.DEFAULT_RETURN_BELOW_PERCENT,
|
||||||
vehicleIds = {},
|
vehicleIds = {},
|
||||||
|
chain = "",
|
||||||
}
|
}
|
||||||
new.nextId = new.nextId + 1
|
new.nextId = new.nextId + 1
|
||||||
table.insert(new.runs, run)
|
table.insert(new.runs, run)
|
||||||
@@ -204,6 +206,7 @@ function ADRuns.updateRun(store, runId, changes)
|
|||||||
if changes.storeAbovePercent ~= nil then run.storeAbovePercent = clampRange(changes.storeAbovePercent, ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT) end
|
if changes.storeAbovePercent ~= nil then run.storeAbovePercent = clampRange(changes.storeAbovePercent, ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT) end
|
||||||
if changes.sellAbovePercent ~= nil then run.sellAbovePercent = clampRange(changes.sellAbovePercent, ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT) end
|
if changes.sellAbovePercent ~= nil then run.sellAbovePercent = clampRange(changes.sellAbovePercent, ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT) end
|
||||||
if changes.collectRound ~= nil then run.collectRound = changes.collectRound == true end
|
if changes.collectRound ~= nil then run.collectRound = changes.collectRound == true end
|
||||||
|
if changes.chain ~= nil then run.chain = tostring(changes.chain) end
|
||||||
return new
|
return new
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -440,6 +443,7 @@ function ADRuns.toRecords(store)
|
|||||||
collectRound = run.collectRound and 1 or 0,
|
collectRound = run.collectRound and 1 or 0,
|
||||||
stopped = run.stopped and 1 or 0,
|
stopped = run.stopped and 1 or 0,
|
||||||
wagons = ADRuns.serializeWagons(run.wagons),
|
wagons = ADRuns.serializeWagons(run.wagons),
|
||||||
|
chain = run.chain or "",
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
return records
|
return records
|
||||||
@@ -494,6 +498,7 @@ function ADRuns.fromRecords(records)
|
|||||||
vehicleIds = copyList(record.vehicleIds),
|
vehicleIds = copyList(record.vehicleIds),
|
||||||
stopped = tonumber(record.stopped) == 1,
|
stopped = tonumber(record.stopped) == 1,
|
||||||
wagons = ADRuns.parseWagons(record.wagons),
|
wagons = ADRuns.parseWagons(record.wagons),
|
||||||
|
chain = record.chain or "",
|
||||||
})
|
})
|
||||||
store.nextId = math.max(store.nextId, id + 1)
|
store.nextId = math.max(store.nextId, id + 1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ function ADRunsStorage.writeRecords(xmlFile, records)
|
|||||||
-- maskinpulje: flowet stoppet + husket vogn pr. traktor
|
-- maskinpulje: flowet stoppet + husket vogn pr. traktor
|
||||||
xmlFile:setInt(key .. "#stopped", record.stopped or 0)
|
xmlFile:setInt(key .. "#stopped", record.stopped or 0)
|
||||||
xmlFile:setString(key .. "#wagons", record.wagons or "")
|
xmlFile:setString(key .. "#wagons", record.wagons or "")
|
||||||
|
xmlFile:setString(key .. "#chain", record.chain or "")
|
||||||
for vehicleIndex, vehicleId in ipairs(record.vehicleIds) do
|
for vehicleIndex, vehicleId in ipairs(record.vehicleIds) do
|
||||||
xmlFile:setString(string.format("%s.vehicle(%d)#id", key, vehicleIndex - 1), vehicleId)
|
xmlFile:setString(string.format("%s.vehicle(%d)#id", key, vehicleIndex - 1), vehicleId)
|
||||||
end
|
end
|
||||||
@@ -82,6 +83,7 @@ function ADRunsStorage.readRecords(xmlFile)
|
|||||||
collectRound = xmlFile:getInt(key .. "#collectRound"),
|
collectRound = xmlFile:getInt(key .. "#collectRound"),
|
||||||
stopped = xmlFile:getInt(key .. "#stopped"),
|
stopped = xmlFile:getInt(key .. "#stopped"),
|
||||||
wagons = xmlFile:getString(key .. "#wagons"),
|
wagons = xmlFile:getString(key .. "#wagons"),
|
||||||
|
chain = xmlFile:getString(key .. "#chain"),
|
||||||
vehicleIds = {},
|
vehicleIds = {},
|
||||||
}
|
}
|
||||||
xmlFile:iterate(key .. ".vehicle", function(_, vehicleKey)
|
xmlFile:iterate(key .. ".vehicle", function(_, vehicleKey)
|
||||||
|
|||||||
Reference in New Issue
Block a user