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,