I have tried to create a mod that read of the all the ingame generators, and make a primary, secondary and terciary version of them. And then you can use certan keybind to upgrade/downgrade a generators output.
The issues I've gotten into is:
The program crashed when I try to replace the engine, with the error "Lua.entity doesnt contain the key destroy"
the part of the code relevant is:
Code: Select all
script.on_event("decrease-generator-priority", function(event)
local selection = game.players[event.player_index].selected
if selection and selection.type == "generator" then
DecreasePriority(selection, event, force)
end
end
function DecreasePriority(entity, event, force)
if string.find(Name, "-Primary") then
print("The generator is now secondary")
entity.destoy()
if game.prototypes["GP-".. Name .. "-Secondary"] then
surface.create_entity({name = "GP-".. Name .. "-Secondary", postition = Pos, direction = Rot, force = force})
else
print("Missing the generator")
end
end
and 2.
Is there a way to generate the Locale on the go?
Like can I use
Code: Select all
local file = io.open(__GeneratorPriority__/locale/en/entity.cfg, "w")