News:

Want to praise Simutrans?
Your feedback is important for us ;D.

Using "line.change_schedule(pl, sched)" is giving error

Started by Yona-TYT, October 10, 2022, 02:28:33 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

Something was broken in the simutrans code because this worked without problems.


Dwachs

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 ;)
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

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:

Yona-TYT

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
}


Dwachs

Parsley, sage, rosemary, and maggikraut.

Yona-TYT

#5
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









Yona-TYT

(My apologies to the moderator for the double post) :-[ .

 When routing ships the same error is also encountered.

Dwachs

 ups. Where can I find the latest version of the tutorial?
Parsley, sage, rosemary, and maggikraut.


Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

#10
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