/swap-players event handler

Things that we aren't going to implement
Post Reply
IronCartographer
Filter Inserter
Filter Inserter
Posts: 454
Joined: Tue Jun 28, 2016 2:07 pm
Contact:

/swap-players event handler

Post 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.

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

Re: /swap-players event handler

Post 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?
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.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: /swap-players event handler

Post 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

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

Re: /swap-players event handler

Post 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.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Won't implement”