I am working on some code to put a throttle on production modules
The heavy lifting needs to be done in lua code
I am intending to replace the menu_production code with a customised version.
menu_production gets passed two parameters, the station and the production module
A lot of stations have more than one production line of the same type.
In a FoodStuffs Supply I need to be able to identify which Valley forge is which. So that I can adjust the throttle later, on the right one.
Obviously I cannot use objectID as they change every time the game is reloaded.
Is it possible to get the build stage of a particular production module or find a couple of parameters that combined together uniquely identify a specfic production module within a station ?
It needs to be valid over save games and survive the player extending the station ....
jth
EDIT 18:40
Put together some code borrowed heavily from menu_buildtree.lua that goes through the station buildtree and finds the buildstage for each production module
Code: Select all
DebugError("Station is " .. GetComponentData(menu.object, "name"))
DebugError("Module is " .. GetComponentData(menu.module, "name"))
DebugError("Module " .. tostring(menu.module))
menu.buildtree = GetBuildTree(menu.object)
table.sort(menu.buildtree, function (a, b) return a.name < b.name end)
for seqidx, seqdata in ipairs(menu.buildtree) do
if seqdata.sequence == "a" then
modules = GetBuildStageModules(menu.object, "", 0)
for _, module in ipairs(modules) do
if module.library == "moduletypes_production" then
DebugError("[a,0] " .. module.name .. " " .. tostring(module.component))
end
end
end
for stageidx, stagedata in ipairs(seqdata) do
if stagedata.stage <= seqdata.currentstage or menu.task == "building" then
DebugError("[" .. seqdata.sequence .. "," .. stagedata.stage .. "] " .. stagedata.name .. " " .. tostring(stagedata.primarycomponent))
end
end
end
results
[General] ======================================
[=ERROR=] Station is Foodstuffs Supply I
[General] ======================================
[General] ======================================
[=ERROR=] Module is Liquor Still
[General] ======================================
[General] ======================================
[=ERROR=] Module ID:
16881844
[General] ======================================
[General] ======================================
[=ERROR=] [a,0] Foodstuff Fac ID: 16819627
[General] ======================================
[General] ======================================
[=ERROR=] [a,1] Foodstuff Fac ID: 16878931
[General] ======================================
[General] ======================================
[=ERROR=] [b,1] Valley Forge ID: 16819617
[General] ======================================
[General] ======================================
[=ERROR=] [b,2] Valley Forge ID: 16879060
[General] ======================================
[General] ======================================
[=ERROR=] [c,1] Liquor Still ID:
16881844
[General] ======================================
[General] ======================================
[=ERROR=] [d,1] Argnu Paradise ID: 16879153
[General] ======================================
[General] ======================================
[=ERROR=] [e,1] Spice Tubes ID: 16803969
[General] ======================================
[General] ======================================
[=ERROR=] [f,1] Container Storage ID: 16882068
[General] ======================================
A good days work