Page 1 of 1

/swap-players event handler

Posted: Wed Mar 25, 2020 7:14 pm
by IronCartographer
Using /swap-players breaks some mods without a clean way to handle it. Discovered as a result of Klonan's Construction Drones ceasing to function.

Re: /swap-players event handler

Posted: Wed Mar 25, 2020 7:35 pm
by eradicator
Never heared of that command but the in-game help says it just changes the character that is associated with a player. That can happen at any time without notification when any mod calls LuaPlayer.character = LuaEntity. So the event would have to notify any changes to LuaPlayer.character and LuaPlayer.get_associated_characters().

For the meantime i think the "clean way" to handle this would be not to assume anything about Player<->Character associations. Have you notified Klonan of his bug?

Re: /swap-players event handler

Posted: Wed Mar 25, 2020 7:41 pm
by Klonan
eradicator wrote:
Wed Mar 25, 2020 7:35 pm
For the meantime i think the "clean way" to handle this would be not to assume anything about Player<->Character associations. Have you notified Klonan of his bug?
My mod doesn't care about the player, only the character

The problem is, the character just pops into existance, with nothing telling my mod there is a new character entity running around

Re: /swap-players event handler

Posted: Thu Mar 26, 2020 5:28 pm
by Rseding91
I don't see this as happening. There are a multitude of different ways the character entity can be swapped out on a player. Having events for all of them isn't something I want to maintain on the C++ side due to how much stuff mods can break every time the game calls a mod event handler.

For example:

Console commands, setting the controller on a player, a migration changing the character entity to another, the swap command, deleting the character by destroy(), deleting it via the map editor, and i'm sure others.

It's similar to the "item added/removed" event; it happens in so many different cases in so many different ways that the game would have to try to guard against mods breaking stuff during all of those cases and that's just too much so we don't provide those events.