When this button is pressed for the first time, the function: "is_schedule_allowed (pl, schedule)" does not work.
(http://files.simutrans.com/index.php/apps/files_sharing/ajax/publicpreview.php?x=1440&y=372&a=true&file=line%2520error.png&t=cygIWt7qhpnq0UC&scalingup=0)
I must wait for this to be able to launch a new version of the tutorial. ;)
Is_schedule_allowed is only called when the schedule of a line or a line-less convoy is changed.
Quote from: Dwachs on May 26, 2017, 06:23:50 AM
Is_schedule_allowed is only called when the schedule of a line or a line-less convoy is changed.
And why not work here too? ???
The schedule should have been checked before already.
I'd really like to solve this. :-[
Maybe if you implement a function that allows you to check the lines. ???
Example: is_line_allowed (pl, line)
This can be called each time the "Promote to line" button is pressed.
Why, the line is valid for that kind of transport?
Quote from: prissi on July 18, 2017, 02:21:52 AM
Why, the line is valid for that kind of transport?
Actually I only need to check the Schedule before creating the line, with the class line_x you can do that and much more. ;)
The schedule was already created, so the function has already fired before promoting to line. If you want to know when a schedule was promoted to line then I guess it would make more sense to have another event, like on_schedule_to_line.
Maybe a new topic?. ???
see r8270: promote to line will call is_schledule_allowed.
Quote from: Dwachs on July 22, 2017, 01:57:49 PM
see r8270: promote to line will call is_schledule_allowed.
Thank you, now I can solve a problem that did not allow me to sleep peacefully. ;D
Something of music here: ;)
@Dwachs
Two important details:
1. If the schedule is not correct, the line should not be allowed to be created.
2. If the schedule is not correct, the list should be cleared.
This is much better for me: ;)
simutool.cc (line 6856)
if (!scenario_check_schedule(welt, player, line->get_schedule(), can_use_gui())) {
player->simlinemgmt.delete_line(line);
break;
}
But I still have a problem, I need to differentiate between the call when you press the "Promote to line" button and when the "Schedule" window is closed .. is it possible in any way ?. ???
Quote from: Yona-TYT on July 24, 2017, 10:43:13 AM
But I still have a problem, I need to differentiate between the call when you press the "Promote to line" button and when the "Schedule" window is closed .. is it possible in any way ?. ???
no, this is not possible.
Quote from: Dwachs on July 24, 2017, 12:01:29 PM
no, this is not possible.
And clean the schedule list ?.
@Dwachs
Quote from: Yona-TYT on July 24, 2017, 10:43:13 AM
This is much better for me: ;)
simutool.cc (line 6856)
if (!scenario_check_schedule(welt, player, line->get_schedule(), can_use_gui())) {
player->simlinemgmt.delete_line(line);
break;
}
I'm afraid there's a problem with this. :-[
It seems that when I create a line "pl.create_line (wt)" it is deleted immediately.
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)
convoy[0].set_line(pl, c_line)
depot.start_convoy(pl, convoy[0])
this.step_nr(5)
(http://files.simutrans.com/index.php/apps/files_sharing/ajax/publicpreview.php?x=1440&y=372&a=true&file=sche_error.png&t=sJLQ1B1malVVwid&scalingup=0)
Edit.
Luckily find a simple solution using a flag before using "pl.create_line(wt)". ;)
lin_flag = true
pl.create_line(wt)
function is_schedule_allowed(pl, schedule)
{
if (lin_flag){
lin_flag = false
return null
}
}
Imho. this is a problem of your script: It should accept empty schedules.
@Dwachs
I am very happy to see this problem solved. thank you very much!. ;D
You can try the script here:
Script -> tutorial-test-lines.zip (http://files.simutrans.com/index.php/s/iBuVKwHIv8qPTnF)
Savegame -> test-tuto.sve (http://files.simutrans.com/index.php/s/jISL5bZpnxInaCl)
(http://files.simutrans.com/index.php/apps/files_sharing/ajax/publicpreview.php?x=1440&y=372&a=true&file=tutorial-v6.2.png&t=VCFb06cXPs0OZ94&scalingup=0)