News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

Edit line Lines function

Started by Yona-TYT, May 31, 2020, 11:59:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT



[line_x.update_line(player_x schedule_x)]
I want to fix a little problem with the lines in the tutorial scenario.

Dwachs

?? What should this function do, and why do you want such a function?
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

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.

Dwachs

There is line_x::change_schedule. What else do you want?
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Certainly yes, I had already tried to use it in the past, sorry I forgot about that. :o

Yona-TYT

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

Dwachs

Why do you want to create a line within this function? What is the error?
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

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.

Dwachs

Could you upload a savegame, script, and instructions to reproduce this? This looks like some bug.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

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

Dwachs

thanks, will look into this. It might tak a while.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

#11
I think because "line.change schedule(play, schedule)" calls the same function "is_schedule_allowed (pl, schedule)" this must be creating some conflict?.  ???

Yona-TYT

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)

Dwachs

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

Yona-TYT


Yona-TYT

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", but the problem still persists.

In fact put a counter and it runs about 50 times before giving the error.

Dwachs

missed one, should work with r9150
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Thank you very much, now it works and I have solved the problem .    ;D