Add joinable legacy code

This commit is contained in:
Cooldude2606
2024-09-23 23:01:52 +01:00
parent 2a1206c498
commit d24555d805
24 changed files with 144 additions and 126 deletions

View File

@@ -96,9 +96,12 @@ end
-- @tparam string item_name the name of the item that you want the data about
-- @treturn table contains total made, used and net
function Production.get_production_total(force, item_name)
local stats = force.item_production_statistics
local made = stats.get_input_count(item_name) or 0
local used = stats.get_output_count(item_name) or 0
local made, used = 0, 0
for _, surface in pairs(game.surfaces) do
local stats = force.get_item_production_statistics(surface)
made = made + stats.get_input_count(item_name)
used = used + stats.get_output_count(item_name)
end
return {
made=made,
@@ -114,9 +117,12 @@ end
-- @tparam defines.flow_precision_index precision the precision that you want the data given to
-- @treturn table contains made, used and net
function Production.get_production(force, item_name, precision)
local stats = force.item_production_statistics.get_flow_count
local made = stats{name=item_name, input=true, precision_index=precision} or 0
local used = stats{name=item_name, input=false, precision_index=precision} or 0
local made, used = 0, 0
for _, surface in pairs(game.surfaces) do
local stats = force.get_item_production_statistics(surface).get_flow_count
made = made + stats{name=item_name, category="input", precision_index=precision}
used = used + stats{name=item_name, category="output", precision_index=precision}
end
return {
made=made,

View File

@@ -110,7 +110,7 @@ Gui.element(function(definition, parent, target)
local label = parent.add{
type = 'label',
style = 'heading_1_label',
style = 'frame_title',
caption = 'Following '..target.name..'.\nClick here or press esc to stop following.',
name = definition.name
}

View File

@@ -573,7 +573,7 @@ local function handle_circuit_interfaces()
-- Set the item signals based on stored items
for item_name, count in pairs(vlayer_data.storage.items) do
if game.item_prototypes[item_name] and count > 0 then
if prototypes.item[item_name] and count > 0 then
circuit_oc.set_signal(signal_index, {signal={type='item', name=item_name}, count=count})
signal_index = signal_index + 1
if signal_index > max_signals then