My use-case for this is: I want to cache the colors of entities so I don't need to access entity.color over and over to get the color, by listening for the event I can just cache the color when it changes and look it up later. But if it changes to nil and the event is not raised then my cache won't be updated and will still think the entity has a color, making the cache inaccurate.
Steps to reproduce:
1. start a new save and spawn in some entities that can be colored, like locomotives.
2. paste the following script into chat to print a message when the event triggers
Code: Select all
/c
script.on_event(defines.events.on_entity_color_changed, function(event)
game.print({"", event.entity.localised_name, " color changed to: ", serpent.line(event.entity.color)})
end)
Code: Select all
/c game.player.selected.color = {1,1,1}
5. select the entity again and paste the following command to change its color to nil
Code: Select all
/c game.player.selected.color = nil