Page 1 of 1

LuaTrain.go_to_station()

Posted: Mon Oct 15, 2018 7:42 pm
by Reika
Exactly what it looks like - a function to call on a LuaTrain to send it to a given station.

Re: LuaTrain.go_to_station()

Posted: Tue Oct 16, 2018 1:56 am
by quyxkh
Does

Code: Select all

/c _=game.player.selected.train _.schedule={current=1,records={{station='NE Iron Plate'}}} _.manual_mode=false
do what you want?

Re: LuaTrain.go_to_station()

Posted: Tue Oct 16, 2018 2:20 am
by Reika
quyxkh wrote: Tue Oct 16, 2018 1:56 am Does

Code: Select all

/c _=game.player.selected.train _.schedule={current=1,records={{station='NE Iron Plate'}}} _.manual_mode=false
do what you want?
No, because I am not interested in deleting the train's normal schedule.

Re: LuaTrain.go_to_station()

Posted: Tue Oct 16, 2018 4:47 am
by Bilka
Okay, added for 0.17.

Re: LuaTrain.go_to_station()

Posted: Tue Jan 15, 2019 4:07 pm
by Fractaliste
Bilka wrote: Tue Oct 16, 2018 4:47 am Okay, added for 0.17.
Will the new station appears into the ScheduleRecords array?

Re: LuaTrain.go_to_station()

Posted: Tue Jan 15, 2019 4:11 pm
by Bilka
Fractaliste wrote: Tue Jan 15, 2019 4:07 pm Will the new station appears into the ScheduleRecords array?
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.

Re: LuaTrain.go_to_station()

Posted: Tue Jan 15, 2019 5:06 pm
by Optera
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

Re: LuaTrain.go_to_station()

Posted: Tue Jan 15, 2019 5:53 pm
by Bilka
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
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.

Re: LuaTrain.go_to_station()

Posted: Tue Jan 15, 2019 6:05 pm
by Optera
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.

Re: LuaTrain.go_to_station()

Posted: Thu Jan 17, 2019 1:55 pm
by Fractaliste
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.
Is was this way I initially understand the new LuaTrain.go_to_station() functionnality.

Re: LuaTrain.go_to_station()

Posted: Fri Jun 07, 2019 6:02 am
by Reika
Fractaliste wrote: Thu Jan 17, 2019 1:55 pm
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.
Is was this way I initially understand the new LuaTrain.go_to_station() functionnality.
And it was how I intended it.

Re: LuaTrain.go_to_station()

Posted: Fri Jun 07, 2019 6:49 am
by Bilka
Please make a new request and describe exactly what you want.

Re: LuaTrain.go_to_station()

Posted: Fri Jun 07, 2019 2:49 pm
by Reika
Bilka wrote: Fri Jun 07, 2019 6:49 am Please make a new request and describe exactly what you want.
Done. viewtopic.php?f=28&t=71679