Request for scripting, how to turn off indestructible

Anything that prevents you from playing the game properly. Do you have issues playing for the game, downloading it or successfully running it on your computer? Let us know here.
Post Reply
Dark_star
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Mon Feb 10, 2014 9:07 pm
Contact:

Request for scripting, how to turn off indestructible

Post by Dark_star »

Request for scripting, how to turn off indestructible
Is it possible to put a script into control.lau to change map items from indestructible to normal destructible?
thanks

P.S. opening editor for each and on turning it off is a drag

Adamo
Filter Inserter
Filter Inserter
Posts: 479
Joined: Sat May 24, 2014 7:00 am
Contact:

Re: Request for scripting, how to turn off indestructible

Post by Adamo »

Depending what you're doing, maybe. From https://lua-api.factorio.comlatest/LuaEntity.html:

Code: Select all

destructible :: boolean [Read-Write]

When the entity is not destructible it can't be damaged.

Note: An indestructible entity can still be mined.
Note: Entities that are indestructible naturally (they have no health, like smoke, resource etc) can't be set to be destructible.


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

Re: Request for scripting, how to turn off indestructible

Post by eradicator »

Code: Select all

/c for _,entity in pairs(game.surfaces.nauvis.find_entities()) do entity.destructible = true end
Will be really slow on large maps. Might also break some mods if they rely on hidden entities. If you know *what* kind of entity you want to change you can use find_entities_filtered(). Depending on what you're dealing with you might also want to set minable = true.
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.

Koub
Global Moderator
Global Moderator
Posts: 7199
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Request for scripting, how to turn off indestructible

Post by Koub »

[Koub] Moved to Technical Help.
Koub - Please consider English is not my native language.

Post Reply

Return to “Technical Help”