How to make the output energy dependent on the global variable?
I make some mod, that contain variable in global (because they are tied to the number of objects launched into space). And a certain entity must generate energy in the amount of global.variable / entity.name count in this world * 100Kw. How do I do this?
I only start learning lua (i know С++ and C#) and factorio modding, sorry if this is a stupid question
Output energy dependent on the global variable
Re: Output energy dependent on the global variable
data.raw:
control.lua:
Code: Select all
local my_generator = table.deepcopy(data.raw["electric-energy-interface"]["crash-site-generator"])
my_generator.name = "my-generator"
data:extend{my_generator}
Code: Select all
function change_output(surface, force, entity_name)
local entities = surface.find_entities_filtered{force=force, name=entity_name}
for _, entity in pairs(entities) do
entity.power_production = global.variable / #entities * 100000 / 60
end
end
Re: Output energy dependent on the global variable
Where do I need to call this function from? I can't find anything suitable in LuaSurface