[2.0.37] LuaSchedule::add_record adds temporary stops at the beginning of the schedule

Things that has been reported already before.
User avatar
hgschmie
Fast Inserter
Fast Inserter
Posts: 113
Joined: Tue Feb 06, 2024 5:18 am
Contact:

[2.0.37] LuaSchedule::add_record adds temporary stops at the beginning of the schedule

Post by hgschmie »

( this is a debugging session with an actual train and schedule )

Code: Select all

> for i = 1, train_schedule.get_record_count() do print(serpent.line(train_schedule.get_record{ schedule_index = i })) end
(nil)
> train_schedule.add_record { station = 'zzz_first' }
> train_schedule.add_record { station = 'aaa_second' }
> for i = 1, train_schedule.get_record_count() do print(serpent.line(train_schedule.get_record{ schedule_index = i })) end
{allows_unloading = true, created_by_interrupt = false, station = "zzz_first", temporary = false, wait_conditions = {}}
{allows_unloading = true, created_by_interrupt = false, station = "aaa_second", temporary = false, wait_conditions = {}}
(nil)

ok, so adding two regular stops in order works. "aaa_second" gets added after 'zzz_first'

Code: Select all

> for i = 1, train_schedule.get_record_count() do print(serpent.line(train_schedule.get_record{ schedule_index = i })) end
(nil)
> train_schedule.add_record { station = 'zzz_first' }
> train_schedule.add_record { station = 'aaa_second', temporary = true }
> for i = 1, train_schedule.get_record_count() do print(serpent.line(train_schedule.get_record{ schedule_index = i })) end
{allows_unloading = true, created_by_interrupt = false, station = "aaa_second", temporary = true, wait_conditions = {{compare_type = "and", ticks = 300, type = "time"}}}
{allows_unloading = true, created_by_interrupt = false, station = "zzz_first", temporary = false, wait_conditions = {}}
(nil)
But a temporary stop gets added at the top of the schedule, not the bottom. The docs state Adds a record to the end of the current schedule using the provided data.
User avatar
hgschmie
Fast Inserter
Fast Inserter
Posts: 113
Joined: Tue Feb 06, 2024 5:18 am
Contact:

Re: [2.0.37] LuaSchedule::add_record adds temporary stops at the beginning of the schedule

Post by hgschmie »

It seems slightly more complicated. If the first stop is a temporary stop, then the new stop is put *behind* that temporary stop but *before* the first permanent stop:

Code: Select all

> for i = 1, train_schedule.get_record_count() do print(serpent.line(train_schedule.get_record{ schedule_index = i })) end
(nil)
train_schedule.add_record { station = "test", temporary = true }
(nil)
train_schedule.add_record { station = "test2", }
(nil)
for i = 1, train_schedule.get_record_count() do print(serpent.line(train_schedule.get_record{ schedule_index = i })) end
{allows_unloading = true, created_by_interrupt = false, station = "test", temporary = true, wait_conditions = {{compare_type = "and", ticks = 300, type = "time"}}}
{allows_unloading = true, created_by_interrupt = false, station = "test2", temporary = false, wait_conditions = {}}
(nil)
train_schedule.add_record { station = "test3", temporary = true }
(nil)
for i = 1, train_schedule.get_record_count() do print(serpent.line(train_schedule.get_record{ schedule_index = i })) end
{allows_unloading = true, created_by_interrupt = false, station = "test", temporary = true, wait_conditions = {{compare_type = "and", ticks = 300, type = "time"}}}
{allows_unloading = true, created_by_interrupt = false, station = "test3", temporary = true, wait_conditions = {{compare_type = "and", ticks = 300, type = "time"}}}
{allows_unloading = true, created_by_interrupt = false, station = "test2", temporary = false, wait_conditions = {}}
(nil)
robot256
Smart Inserter
Smart Inserter
Posts: 1121
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [2.0.37] LuaSchedule::add_record adds temporary stops at the beginning of the schedule

Post by robot256 »

As Rseding has said, the new interface replicates the user interface almost exactly. This sounds like it's replicating the intentionally broken insertion of temporary stops as described here: viewtopic.php?t=118266

2.0.38 should have the ability to pass an index into add_record() that will hopefully bypass the broken logic.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15224
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.37] LuaSchedule::add_record adds temporary stops at the beginning of the schedule

Post by Rseding91 »

Semi-duplicate of 127180
If you want to get ahold of me I'm almost always on Discord.
robot256
Smart Inserter
Smart Inserter
Posts: 1121
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [2.0.37] LuaSchedule::add_record adds temporary stops at the beginning of the schedule

Post by robot256 »

Rseding91 wrote: Fri Feb 28, 2025 1:32 pm Semi-duplicate of 127180
Any chance of getting more detail on viewtopic.php?t=118266 ? I still don't see how it was a useful change. With the new API we can make a mod to fix it, which is great, but that doesn't explain the regression in usability.
Post Reply

Return to “Duplicates”