get_train_stop_trains() behaviour when station name changed

Bugs that are actually features.
Post Reply
User avatar
Sandman2003
Long Handed Inserter
Long Handed Inserter
Posts: 67
Joined: Sun Nov 30, 2014 5:02 am
Contact:

get_train_stop_trains() behaviour when station name changed

Post by Sandman2003 »

If you have a single station with a train parked at it and you change the station name, then 'event.entity.get_train_stop_trains()' correctly returns the train that was in the single train stop. However, if there are more than one train stops with the same name, and a train is parked in one of these train stops and you change the train stop's name, then the same function, 'event.entity.get_train_stop_trains()' is unable to return that train. As this is based off the entity, not the backer name it should be able to function correctly.

This event is within a "script.on_event(defines.events.on_entity_renamed, function(event)" code block

In the single station case, the return looks like this -
{
{
__self = "userdata: 0x000000006d54bce0"
}
}

When there is more than one station with the same name (ie backer_name) then you get -
{}

(Results per game.write_file("trains",serpent.block(trains),{comment=false}))

- it is possible this is related to the same issue you fixed for 0.17 "Crash on LuaEntity.get_train_stop_trains() + train change" - however, I am not sure of this

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

Re: get_train_stop_trains() behaviour when station name changed

Post by Rseding91 »

Thanks for the report however this is working correctly. get_train_stop_trains() does not work based off entity but off the train stop name.

Additionally: train schedules won't be changed if there's still another train stop with the original name.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Sandman2003
Long Handed Inserter
Long Handed Inserter
Posts: 67
Joined: Sun Nov 30, 2014 5:02 am
Contact:

Re: get_train_stop_trains() behaviour when station name changed

Post by Sandman2003 »

I did actually ask about this one in discord first (mod_making). Anyway, my workaround works so it is all good. (And I knew about the train schedule, I assumed that was a consequence, but it seems it is more like the reason for this behaviour)

Post Reply

Return to “Not a bug”