Page 1 of 1
Editor Lua Snippets
Posted: Sat Feb 01, 2020 4:29 pm
by D4rkL0rd
Hello,
I am trying to program some editor snippets but I can't get it to work (i'm not a programmer)

I just want to set all objects in the selection to indestructible/not minable/ not rotatable. Can anybody help?
Re: Editor Lua Snippets
Posted: Sun Feb 09, 2020 4:22 pm
by eradicator
Never used editor snippets myself. Looks like any command is prepended to include a local variable "area" that is defined as the area you just selected. So you can basically reuse the example snippet:
Code: Select all
function myfunction(entity) --[[edit as you like but don't change name]]
entity.destructible = false
entity.minable = false
entity.rotatable = false
end
--[[don't touch the stuff below]]
local surface = game.player.surface
local entities = surface.find_entities_filtered{area = area}
for _, v in pairs(entities) do myfunction(v) end
Re: Editor Lua Snippets
Posted: Mon Feb 10, 2020 8:12 am
by darkfrei
You can also make a mod, that adds selection tool for do this code for selected entities only:
https://wiki.factorio.com/Prototype/SelectionTool
The vanilla has all prototypes, just look how it was done there.
And for control:
https://lua-api.factorio.com/latest/eve ... ected_area
Also you can add some graphics by "saved" entities with the LuaRendering.