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
get_train_stop_trains() behaviour when station name changed
- Sandman2003
- Long Handed Inserter
- Posts: 67
- Joined: Sun Nov 30, 2014 5:02 am
- Contact:
get_train_stop_trains() behaviour when station name changed
My Mods - Space Extension Mod (SpaceX)
- Train Supply Manager
Sandman2003 is forum name for LordKTor
SpaceX Extreme mode factory
Rocket Launch every second factory(ie 60rpm) - Bobs mod based
- Train Supply Manager
Sandman2003 is forum name for LordKTor
SpaceX Extreme mode factory
Rocket Launch every second factory(ie 60rpm) - Bobs mod based
Re: get_train_stop_trains() behaviour when station name changed
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.
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.
- Sandman2003
- Long Handed Inserter
- Posts: 67
- Joined: Sun Nov 30, 2014 5:02 am
- Contact:
Re: get_train_stop_trains() behaviour when station name changed
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)
My Mods - Space Extension Mod (SpaceX)
- Train Supply Manager
Sandman2003 is forum name for LordKTor
SpaceX Extreme mode factory
Rocket Launch every second factory(ie 60rpm) - Bobs mod based
- Train Supply Manager
Sandman2003 is forum name for LordKTor
SpaceX Extreme mode factory
Rocket Launch every second factory(ie 60rpm) - Bobs mod based