Determining source of deconstruction order

Place to get help with not working mods / modding interface.
Post Reply
kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Determining source of deconstruction order

Post by kds71 »

Wiki says:
onmarkedfordeconstruction

Called when an entity is marked for deconstruction with the Deconstruction planner or via script.
Contains entity, Lua/Entity of the entity marked
Is there any way to determine what caused deconstruction - player or script? And, in case it was done by a player, is it possible to check which player did it?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13220
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Determining source of deconstruction order

Post by Rseding91 »

Right now, no there's not.
If you want to get ahold of me I'm almost always on Discord.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Determining source of deconstruction order

Post by Choumiko »

I assume it's for your upgrade planner?
You could get away with looping through all players in your onmarkedfordeconstruction function. If no player has the deconstruction planner in hand you can go ahead and upgrade, else you can print a message to the player with the upgrade planner to try again. It's a bit ugly, but i guess it should rarely happen, since all the events are raised in 1 tick?

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: Determining source of deconstruction order

Post by kds71 »

Choumiko wrote:I assume it's for your upgrade planner?
You could get away with looping through all players in your onmarkedfordeconstruction function. If no player has the deconstruction planner in hand you can go ahead and upgrade, else you can print a message to the player with the upgrade planner to try again. It's a bit ugly, but i guess it should rarely happen, since all the events are raised in 1 tick?
There would be a problem if more than one player has upgrade planner in hand if these players are not in same team. Still, I think there is no better way to do that, so I might try doing it that way, thanks for the suggestion.

Edit: I just realized that it is not going to work. Example: one player has upgrade planner, another player has deconstruction planner. If player with upgrade planner marks an area, I can't just display the message, I need to cancel deconstruction orders. On other hand, if a player with deconstruction planner was the reason for event call, I can't cancel deconstruction order. Anyway, I don't think it will work well if I can't determine who actually used a planner :(

Post Reply

Return to “Modding help”