Page 1 of 1

Raise an event if color of an entity is changed by player or script

Posted: Sun Mar 12, 2023 2:16 pm
by Pi-C
TLDR:
I need an event that triggers when the color of an entity is changed. The event should support filters, and it should be possible to use it with script.raise_event().
What?
The event on_entity_renamed will be raised whenever the name (actually, it's entity_label) of an entity based on a spider-vehicle prototype is changed. While players can also use the GUI of a spider-vehicle to change its color, no event is raised in this case.

I'd like to get an event that is triggered when an entity's color is changed by a player or per script. Ideally, this event should be raised for any entity prototype. If that isn't feasible, I'd like to get this event at least for entities based on the prototypes that allow players to modify the color (character, locomotive, train-stop, and spider-vehicle). Also, it would be nice if the event could be filtered and if it could be used with script.raise_event(), as that would allow mods to ignore events raised by their own changes.
Use case:
GCKI will set the color of vehicles based on a car or spider-vehicle prototype to the color of the player who has claimed or locked them. Once a vehicle is released, its color will be reset to {r=0, g=0, b=0, a=0} -- even if the player had changed it to another color before GCKI took over.

Usually this is relevant only for spider-vehicles, but the mod Custom Color attaches a color mixer to the GUIs of characters, cars, and fluid/cargo wagons as well (that's why I'd prefer having this event for all kinds of prototypes). I should update my data if a player uses Custom Color to recolor a vehicle, and if my mod recolors a vehicle, Custom Color should update its own data and GUI. We are working on this problem, but let's face it: Having two custom events (both in GCKI and Custom Color) for the same thing isn't as efficient as having one vanilla event we both could listen to.
Even worse, I've another mod that closely interacts with GCKI -- for this mod I'd also have to add a custom event the other mods could respond to!

Re: Raise an event if color of an entity is changed by player or script

Posted: Mon Mar 13, 2023 12:45 pm
by DiRten
As the author of the CustomColor mod, I fully support it.

Re: Raise an event if color of an entity is changed by player or script

Posted: Mon Jun 03, 2024 8:02 am
by Bilka
Hello, this was added at some point: https://lua-api.factorio.com/latest/eve ... or_changed