Author Topic: "Promote to line" button is causing problems.  (Read 1481 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT

"Promote to line" button is causing problems.
« on: May 26, 2017, 03:51:05 AM »

When this button is pressed for the first time, the function: "is_schedule_allowed (pl, schedule)" does not work.




I must wait for this to be able to launch a new version of the tutorial.  ;)

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4251
  • Total likes: 177
  • Helpful: 149
  • Languages: EN, DE, AT
Re: "Promote to line" button is causing problems.
« Reply #1 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.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: "Promote to line" button is causing problems.
« Reply #2 on: May 27, 2017, 01:11:54 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?  ???

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4251
  • Total likes: 177
  • Helpful: 149
  • Languages: EN, DE, AT
Re: "Promote to line" button is causing problems.
« Reply #3 on: May 27, 2017, 03:31:23 PM »
The schedule should have been checked before already.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: "Promote to line" button is causing problems.
« Reply #4 on: July 18, 2017, 01:34:07 AM »
I'd really like to solve this.  :-[

Maybe if you implement a function that allows you to check the lines.  ???
Example:
Code: [Select]
is_line_allowed (pl, line)
This can be called each time the "Promote to line" button is pressed.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8821
  • Total likes: 322
  • Helpful: 229
  • Languages: De,EN,JP
Re: "Promote to line" button is causing problems.
« Reply #5 on: July 18, 2017, 02:21:52 AM »
Why, the line is valid for that kind of transport?

Offline Yona-TYT

Re: "Promote to line" button is causing problems.
« Reply #6 on: July 18, 2017, 01:19:48 PM »
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.  ;)

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2594
  • Total likes: 290
  • Helpful: 89
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
Re: "Promote to line" button is causing problems.
« Reply #7 on: July 18, 2017, 06:02:44 PM »
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.

Offline Yona-TYT

Re: "Promote to line" button is causing problems.
« Reply #8 on: July 21, 2017, 12:05:12 AM »
Maybe a new topic?.  ???

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4251
  • Total likes: 177
  • Helpful: 149
  • Languages: EN, DE, AT
Re: "Promote to line" button is causing problems.
« Reply #9 on: July 22, 2017, 01:57:49 PM »
see r8270: promote to line will call is_schledule_allowed.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: "Promote to line" button is causing problems.
« Reply #10 on: July 22, 2017, 04:38:19 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:  ;)

Offline Yona-TYT

Re: "Promote to line" button is causing problems.
« Reply #11 on: July 23, 2017, 12:21:05 AM »
@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.

Offline Yona-TYT

Re: "Promote to line" button is causing problems.
« Reply #12 on: July 24, 2017, 10:43:13 AM »
This is much better for me:  ;)

simutool.cc (line 6856)
Code: [Select]
                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 ?.  ???

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4251
  • Total likes: 177
  • Helpful: 149
  • Languages: EN, DE, AT
Re: "Promote to line" button is causing problems.
« Reply #13 on: July 24, 2017, 12:01:29 PM »
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.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: "Promote to line" button is causing problems.
« Reply #14 on: July 24, 2017, 12:07:02 PM »
no, this is not possible.

And clean the schedule list ?.

Offline Yona-TYT

Re: "Promote to line" button is causing problems.
« Reply #15 on: July 25, 2017, 11:57:33 PM »
@Dwachs

This is much better for me:  ;)

simutool.cc (line 6856)
Code: [Select]
                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.

Code: [Select]
                    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)



Edit.
Luckily find a simple solution using a flag before using "pl.create_line(wt)". ;)
Code: [Select]
                    lin_flag = true
                    pl.create_line(wt)
Code: [Select]
function is_schedule_allowed(pl, schedule)
{
    if (lin_flag){
        lin_flag = false
        return null
    }
}

« Last Edit: July 26, 2017, 06:49:40 AM by Yona-TYT »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4251
  • Total likes: 177
  • Helpful: 149
  • Languages: EN, DE, AT
Re: "Promote to line" button is causing problems.
« Reply #16 on: July 26, 2017, 07:30:27 AM »
Imho. this is a problem of your script: It should accept empty schedules.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: "Promote to line" button is causing problems.
« Reply #17 on: July 28, 2017, 03:51:39 AM »
@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
Savegame -> test-tuto.sve
« Last Edit: July 28, 2017, 04:17:21 AM by Yona-TYT »