LuaTrain.go_to_station()
LuaTrain.go_to_station()
Exactly what it looks like - a function to call on a LuaTrain to send it to a given station.
Re: LuaTrain.go_to_station()
Does
do what you want?
Code: Select all
/c _=game.player.selected.train _.schedule={current=1,records={{station='NE Iron Plate'}}} _.manual_mode=false
Re: LuaTrain.go_to_station()
No, because I am not interested in deleting the train's normal schedule.quyxkh wrote: Tue Oct 16, 2018 1:56 am Doesdo what you want?Code: Select all
/c _=game.player.selected.train _.schedule={current=1,records={{station='NE Iron Plate'}}} _.manual_mode=false
Re: LuaTrain.go_to_station()
Okay, added for 0.17.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
-
- Inserter
- Posts: 28
- Joined: Wed Dec 06, 2017 9:20 am
- Contact:
Re: LuaTrain.go_to_station()
Will the new station appears into the ScheduleRecords array?
Re: LuaTrain.go_to_station()
See, https://lua-api.factorio.com/0.17.0-pre ... to_station - the station is given by a schedule index, so it must already be in the schedule.Fractaliste wrote: Tue Jan 15, 2019 4:07 pm Will the new station appears into the ScheduleRecords array?
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: LuaTrain.go_to_station()
Isn't this implementation the same as setting the current schedule record?
e.g. if you know you want to send it to the 2nd station in the schedule records:
train.schedule.current = 2
e.g. if you know you want to send it to the 2nd station in the schedule records:
train.schedule.current = 2
My Mods: mods.factorio.com
Re: LuaTrain.go_to_station()
Yes but it's on the C++ side so you don't have to do what the post further up is doing: copying the entire schedule, setting automatic mode etc.Optera wrote: Tue Jan 15, 2019 5:06 pm Isn't this implementation the same as setting the current schedule record?
e.g. if you know you want to send it to the 2nd station in the schedule records:
train.schedule.current = 2
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: LuaTrain.go_to_station()
This function would be really sleek if it took a backer_name as parameter.
Set the index to the corresponding entry or add a new entry for it, potentially with additional parameter taking an list of WaitCondition in case a new entry is generated.
Just for setting current and mode it feels redundant.
I can't think of a use case where you didn't have to find the stop name from the schedule in lua aka read the whole train.schedule.
Already having the schedule in a local table changing current and mode and writing it back to train is simpler to do right there. Even more so if you have to add the desired station in the first place e.g. for something like a player shuttle.
Set the index to the corresponding entry or add a new entry for it, potentially with additional parameter taking an list of WaitCondition in case a new entry is generated.
Just for setting current and mode it feels redundant.
I can't think of a use case where you didn't have to find the stop name from the schedule in lua aka read the whole train.schedule.
Already having the schedule in a local table changing current and mode and writing it back to train is simpler to do right there. Even more so if you have to add the desired station in the first place e.g. for something like a player shuttle.
My Mods: mods.factorio.com
-
- Inserter
- Posts: 28
- Joined: Wed Dec 06, 2017 9:20 am
- Contact:
Re: LuaTrain.go_to_station()
Is was this way I initially understand the new LuaTrain.go_to_station() functionnality.Optera wrote: Tue Jan 15, 2019 6:05 pm This function would be really sleek if it took a backer_name as parameter.
Set the index to the corresponding entry or add a new entry for it, potentially with additional parameter taking an list of WaitCondition in case a new entry is generated.
Re: LuaTrain.go_to_station()
And it was how I intended it.Fractaliste wrote: Thu Jan 17, 2019 1:55 pmIs was this way I initially understand the new LuaTrain.go_to_station() functionnality.Optera wrote: Tue Jan 15, 2019 6:05 pm This function would be really sleek if it took a backer_name as parameter.
Set the index to the corresponding entry or add a new entry for it, potentially with additional parameter taking an list of WaitCondition in case a new entry is generated.
Re: LuaTrain.go_to_station()
Please make a new request and describe exactly what you want.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.