Page 1 of 1
Determining source of deconstruction order
Posted: Fri Apr 10, 2015 11:57 am
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?
Re: Determining source of deconstruction order
Posted: Fri Apr 10, 2015 5:57 pm
by Rseding91
Right now, no there's not.
Re: Determining source of deconstruction order
Posted: Fri Apr 10, 2015 8:49 pm
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?
Re: Determining source of deconstruction order
Posted: Sat Apr 11, 2015 12:12 am
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
