Request for scripting, how to turn off indestructible

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

Request for scripting, how to turn off indestructible

Post by Dark_star » Wed Sep 04, 2019 9:43 pm

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: 358
Joined: Sat May 24, 2014 7:00 am
Contact:

Re: Request for scripting, how to turn off indestructible

Post by Adamo » Wed Sep 04, 2019 9:47 pm

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: 3455
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Request for scripting, how to turn off indestructible

Post by eradicator » Wed Sep 04, 2019 9:52 pm

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: Hand Crank Generator, Screenshot Hotkey 2.0
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: 5030
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Request for scripting, how to turn off indestructible

Post by Koub » Wed Sep 04, 2019 10:04 pm

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

Post Reply

Return to “Technical Help”

Who is online

Users browsing this forum: No registered users