[line_x.update_line(player_x schedule_x)]
I want to fix a little problem with the lines in the tutorial scenario.
?? What should this function do, and why do you want such a function?
Sorry for not explaining well, I mean the "edit line" button. :-[
It is the same as the "Edit line" button in the lines window.
In some cases, I need to change the minimum load or wait time on an already existing line. I think the only way to do that correctly is to use the "Edit line" button in the lines window.
If one tries to change the minimum load or the waiting time on an existing line for a vehicle, if you use the copy button, the new vehicles do not receive the change in the minimum load or time, they keep the values that were used when creating the line.
There is line_x::change_schedule. What else do you want?
Certainly yes, I had already tried to use it in the past, sorry I forgot about that. :o
Quote from: Dwachs on June 08, 2020, 12:26:13 PMThere is line_x::change_schedule. What else do you want?
Using "line.change_schedule(play, schedule)" in the "is_schedule_allowed (pl, schedule)" function causes error.
This is what I am trying to do:You must create a line with the same name "Test 1".
function is_schedule_allowed(pl, schedule)
{
local line_name = "Test 1"
local play = player_x(pl)
local list = play.get_line_list()
foreach(line in list) {
if (line.get_name() == line_name && line.get_waytype() == wt_road){
line.change_schedule(play, schedule)
}
}
return null
}
Is it possible to make this work?.
Why do you want to create a line within this function? What is the error?
What I want to do is update the line with the correct "schedule", so when copying the convoy the minimum load and waiting time values should be correct for the resulting convoys.
I try to solve this: https://forum.simutrans.com/index.php/topic,19987.0.html
The error is shown in the attached image.
Could you upload a savegame, script, and instructions to reproduce this? This looks like some bug.
Savegame -> https://www.mediafire.com/file/utfbrccczf1pvhr/test_line_err.sve/file
To replicate open the "schedule" window of the convoy stored in the garage, at the moment of closing you will notice the error.
You can use this minama test script (there is nothing else I can infer).
thanks, will look into this. It might tak a while.
I think because "line.change schedule(play, schedule)" calls the same function "is_schedule_allowed (pl, schedule)" this must be creating some conflict?. ???
A possible solution for me will be to add a new function that is called from the [copy convoy] button.
Something like "is_convoy_copy_allowed (pl, convoy, depot)" from that function there should be no problem running "line.change schedule (play, schedule)". 8)
This is a stack overflow due to all these recursive calls. The error message is misleading. I will disable the call to is_schedule_allowed if change_line is called by scenario script.
Edit: done with r9147
seems reasonable to me :)
Quote from: Dwachs on June 19, 2020, 06:15:13 AMThis is a stack overflow due to all these recursive calls. The error message is misleading. I will disable the call to is_schedule_allowed if change_line is called by scenario script. Edit: done with r9147
I have applied your patch "https://github.com/aburch/simutrans/commit/732372dd5a1c85ba81fec89a03ad3d11b1ae235f (https://github.com/aburch/simutrans/commit/732372dd5a1c85ba81fec89a03ad3d11b1ae235f)", but the problem still persists.
In fact put a counter and it runs about 50 times before giving the error.
(https://www.mediafire.com/convkey/a491/c0rdwuvpkawffh86g.jpg)
missed one, should work with r9150
Thank you very much, now it works and I have solved the problem . ;D