Page 1 of 1

[raiguard][1.1.83] defines.events.on_entity_color_changed is not raised

Posted: Thu Jun 15, 2023 9:57 am
by Pi-C
In Factorio 1.1.83, the event on_entity_color_changed has been added -- thanks for that! Unfortunately, it seems the event won't be raised.

To reproduce, start a new game, then run this on the command line:

Code: Select all

/c  script.on_event(defines.events.on_entity_damaged, function(event)game.print(string.format("Damaged entity: %s (%s)", event.entity.name, event.entity.unit_number)) end)
    script.on_event(defines.events.on_entity_color_changed, function(event)game.print(string.format("New color of %s (%s): %s", event.entity.name, event.entity.unit_number, serpent.line(event.entity.color))) end)
    p = game.player; red = {r = 1, a = 1}; green = {g = 1, a = 1}
    car = p.surface.create_entity{name = "car", position = {p.position.x+2, p.position.y}, force = p.force}
This will create an event handler for the new event, and a handler for on_entity_damaged that we'll use for reference.

If you run

Code: Select all

/c car.damage(50, p.force, "physical", p.character)
you'll get the expected message that the car has been damaged. If you now try running

Code: Select all

/c car.color = red
you'll get no output. Now, just to make sure that the car's color wasn't "red" to begin with, try

Code: Select all

/c car.color = green
Again, there isn't any output.

Re: [raiguard][1.1.83] defines.events.on_entity_color_changed is not raised

Posted: Fri Jun 16, 2023 5:13 pm
by raiguard
Thanks for the report, this has been fixed for the next release.

Re: [raiguard][1.1.83] defines.events.on_entity_color_changed is not raised

Posted: Sat Jun 17, 2023 4:53 pm
by Pi-C
Thank you very much for the quick fix! I've already updated the first of my mods which will use the event. :-)