The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on October 10, 2022, 02:28:33 AM

Title: Using "line.change_schedule(pl, sched)" is giving error
Post by: Yona-TYT on October 10, 2022, 02:28:33 AM
Something was broken in the simutrans code because this worked without problems.

Title: Re: Using "line.change_schedule(pl, sched)" is giving error
Post by: Dwachs on October 10, 2022, 09:30:45 AM
Can you verify whether it works in r10737 but not in r10738? This seems to be the only relevant change.

Can you provide a savegame right before this is triggered? I do not want to play the whole tutorial to debug this ;)
Title: Re: Using "line.change_schedule(pl, sched)" is giving error
Post by: Yona-TYT on October 10, 2022, 11:23:38 AM
Quote from: Dwachs on October 10, 2022, 09:30:45 AMCan you verify whether it works in r10737 but not in r10738? This seems to be the only relevant change.
Can you provide a savegame right before this is triggered? I do not want to play the whole tutorial to debug this ;)
I still don't know how to get past reviews I'm afraid. 


Attached the savegame:
Title: Re: Using "line.change_schedule(pl, sched)" is giving error
Post by: Yona-TYT on October 10, 2022, 11:27:37 AM
You just have to click on the link "Go to next step". ;)
function comm_start_convoy(pl, wt, sched, cov_list, depot)
{
pl.create_line(wt)
// find the line - it is a line without schedule and convoys
local list = pl.get_line_list()
local c_line = null
foreach(line in list) {
if (line.get_waytype() == wt  &&  line.get_schedule().entries.len()==0) {
// right type, no schedule -> take this.
c_line = line
break
}
}
c_line.change_schedule(pl, sched)
for(local j = cov_list.len()-1; j>=0;j--){

try {
cov_list[j].set_line(pl, c_line)
depot.start_convoy(pl, cov_list[j])
}
catch(ev) {
continue
}
}
return null
}

Title: Re: Using "line.change_schedule(pl, sched)" is giving error
Post by: Dwachs on October 10, 2022, 05:49:10 PM
should work again in r10769
Title: Re: Using "line.change_schedule(pl, sched)" is giving error
Post by: Yona-TYT on October 10, 2022, 06:07:59 PM
Quote from: Dwachs on October 10, 2022, 05:49:10 PMshould work again in r10769
Very happy to read that, thank you very much!. :thumbsup:


By the way, it's funny that the tutorial works as automated tests hehehehehehehe.

 Real automated tests failed to detect this. :P








Title: Re: Using "line.change_schedule(pl, sched)" is giving error
Post by: Yona-TYT on October 10, 2022, 09:28:20 PM
(My apologies to the moderator for the double post) :-[ .

 When routing ships the same error is also encountered.
Title: Re: Using "line.change_schedule(pl, sched)" is giving error
Post by: Dwachs on October 11, 2022, 06:17:55 AM
 ups. Where can I find the latest version of the tutorial?
Title: Re: Using "line.change_schedule(pl, sched)" is giving error
Post by: Yona-TYT on October 11, 2022, 11:05:17 AM
There have been no changes since it was integrated into pak64.

https://github.com/Yona-TYT/tutorial_pak64


Title: Re: Using "line.change_schedule(pl, sched)" is giving error
Post by: Dwachs on October 11, 2022, 04:47:48 PM
This is an error in the script: it tries to add (151, 198, -3) to the ship schedule, but this is the position of the harbour land tile not a water tile.
Title: Re: Using "line.change_schedule(pl, sched)" is giving error
Post by: Yona-TYT on October 11, 2022, 11:21:58 PM
Quote from: Dwachs on October 11, 2022, 04:47:48 PMThis is an error in the script: it tries to add (151, 198, -3) to the ship schedule, but this is the position of the harbour land tile not a water tile.
Changing the coordinates causes a failure with 1-tile docks. :P

So add a function to check if the tile is water or ground.
Edit.
https://github.com/simutrans/tutorial_pak64/commit/ddd6eda7c2f9a6785e2058ea0c35e41f874542ad
https://github.com/simutrans/tutorial_pak64/commit/e48f24a74221f5887f04cbeeea90d3e69199862f ;D