Editor Lua Snippets

Place to get help with not working mods / modding interface.
Post Reply
User avatar
D4rkL0rd
Manual Inserter
Manual Inserter
Posts: 1
Joined: Wed Dec 27, 2017 3:52 am
Contact:

Editor Lua Snippets

Post by D4rkL0rd »

Hello,

I am trying to program some editor snippets but I can't get it to work (i'm not a programmer) :lol: I just want to set all objects in the selection to indestructible/not minable/ not rotatable. Can anybody help?
Not Enough Ingredients

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Editor Lua Snippets

Post 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
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.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Editor Lua Snippets

Post 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.

Post Reply

Return to “Modding help”