Page 1 of 1

[1.1.61] on_entity_renamed doesn't return player_index for spider-vehicle entities

Posted: Wed Jul 27, 2022 3:52 pm
by joscherrer
Hello,

When a player renames a spider-vehicle, the on_entity_renamed event doesn't set the player_index key in the event object.
When renaming a train-stop, the player_index is correctly returned.
The API documentation for on_entity_renamed states that the player_index is not returned only when by_script is true. However in my case it is false.

I used only one mod with the following control.lua :

Code: Select all

script.on_event(defines.events.on_entity_renamed, function (event)
    log("------ on_entity_renamed -------")
    log("---- TYPE : " .. event.entity.type)
    log(serpent.block(event))
end)
Then renamed a spidertron and a train stop. It produced the following logs.

Code: Select all

------ on_entity_renamed -------
---- TYPE : spider-vehicle
{
  by_script = false,
  entity = {
    __self = "userdata"
  },
  name = 59,
  old_name = "",
  tick = 488
}
------ on_entity_renamed -------
---- TYPE : train-stop
{
  by_script = false,
  entity = {
    __self = "userdata"
  },
  name = 59,
  old_name = "TheGoldJoker",
  player_index = 1,
  tick = 488
}
I attached the save (on_entity_renamed.zip), the mod (squadi_0.1.0.zip) and the logs (factorio-current.log).

Re: [1.1.61] on_entity_renamed doesn't return player_index for spider-vehicle entities

Posted: Fri Aug 12, 2022 4:47 pm
by Rseding91
Thanks for the report. It's now fixed for the next release.