LuaTrain.go_to_station()

Post Reply
User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 582
Joined: Tue May 19, 2015 1:56 am
Contact:

LuaTrain.go_to_station()

Post by Reika »

Exactly what it looks like - a function to call on a LuaTrain to send it to a given station.
Image

quyxkh
Smart Inserter
Smart Inserter
Posts: 1027
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: LuaTrain.go_to_station()

Post 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?

User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 582
Joined: Tue May 19, 2015 1:56 am
Contact:

Re: LuaTrain.go_to_station()

Post 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.
Image

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaTrain.go_to_station()

Post by Bilka »

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.

Fractaliste
Inserter
Inserter
Posts: 28
Joined: Wed Dec 06, 2017 9:20 am
Contact:

Re: LuaTrain.go_to_station()

Post 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?

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaTrain.go_to_station()

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: LuaTrain.go_to_station()

Post 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

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaTrain.go_to_station()

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: LuaTrain.go_to_station()

Post 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.

Fractaliste
Inserter
Inserter
Posts: 28
Joined: Wed Dec 06, 2017 9:20 am
Contact:

Re: LuaTrain.go_to_station()

Post 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.

User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 582
Joined: Tue May 19, 2015 1:56 am
Contact:

Re: LuaTrain.go_to_station()

Post 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.
Image

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaTrain.go_to_station()

Post by Bilka »

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.

User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 582
Joined: Tue May 19, 2015 1:56 am
Contact:

Re: LuaTrain.go_to_station()

Post 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
Image

Post Reply

Return to “Implemented mod requests”