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?
Editor Lua Snippets
Editor Lua Snippets
Not Enough Ingredients
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Editor Lua Snippets
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
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Editor Lua Snippets
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.
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.