Author Topic: [line_x] Remove lines  (Read 581 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT

[line_x] Remove lines
« on: July 24, 2017, 08:34:09 PM »

Is there any command to delete lines?  ???

I can think of an idea to solve this: http://forum.simutrans.com/index.php?topic=17140.msg164387#msg164387

But I need to remove lines to achieve it.  ;)

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4247
  • Total likes: 175
  • Helpful: 149
  • Languages: EN, DE, AT
Re: [line_x] Remove lines
« Reply #1 on: July 25, 2017, 07:08:01 AM »
Please check r8274
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: [line_x] Remove lines
« Reply #2 on: July 26, 2017, 05:28:19 AM »
Please check r8274
For some reason the "delete()" function can not be used.  ???


Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4247
  • Total likes: 175
  • Helpful: 149
  • Languages: EN, DE, AT
Re: [line_x] Remove lines
« Reply #3 on: July 26, 2017, 07:20:30 AM »
I see, 'delete' is a language keyword.. will fix tonight.

Edit: fixed in r8275, renamed to 'destroy'
« Last Edit: July 26, 2017, 04:41:31 PM by Dwachs »
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: [line_x] Remove lines
« Reply #4 on: July 28, 2017, 03:34:49 AM »
It does not work as I expected  :-[ , I need a function that allows disassociating the line of vehicles to eliminate them.

I need to remove the lines that are not used, but I receive an error message when I remove the vehicle.

code:

Code: [Select]
function checks_all_line(pl)
{
    local list = player_x(pl).get_line_list()
    local l_nr = list.get_count()
    local line = null
    for(local j=0;j<l_nr;j++){
        line = list[j]
        if (line){
            local cov_nr = 0
            local cov_list = line.get_convoy_list()
            foreach(cov in cov_list) {
                cov_nr++
            }
            if (cov_nr>0)
                continue
            else {
                local sch = line.get_schedule()
                local sch_nr = sch.entries.len()
                if (sch && sch_nr==0){
                    line.destroy(player_x(pl))
                }
            }
        }     
    }
    return null
}


« Last Edit: July 28, 2017, 04:02:16 AM by Yona-TYT »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4247
  • Total likes: 175
  • Helpful: 149
  • Languages: EN, DE, AT
Re: [line_x] Remove lines
« Reply #5 on: July 28, 2017, 06:41:32 AM »
Why would you like to delete a line in a scenario? It can be done: assign all convoys to another line (or destroy them), then destroy the line.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: [line_x] Remove lines
« Reply #6 on: July 28, 2017, 08:39:05 AM »
Why would you like to delete a line in a scenario? It can be done: assign all convoys to another line (or destroy them), then destroy the line.


I just want to remove the lines that are not used.

Any function to know if the line has associated vehicles ?.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4247
  • Total likes: 175
  • Helpful: 149
  • Languages: EN, DE, AT
Re: [line_x] Remove lines
« Reply #7 on: July 29, 2017, 09:17:22 AM »
I just want to remove the lines that are not used.
Imho this is the task of the player.
Quote
Any function to know if the line has associated vehicles ?.
Code: [Select]
line.get_convoy_list().get_count()==0
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: [line_x] Remove lines
« Reply #8 on: July 29, 2017, 01:13:35 PM »
It's not working for me.  :-[

Script: http://files.simutrans.com/index.php/s/3veHwrenSgcEQun

Savegame: http://files.simutrans.com/index.php/s/L4NXqsHEGABY64W

Code: scenario.nut (line 555)
Code: [Select]
function checks_all_line(pl)
{
    local list = player_x(pl).get_line_list()
    local l_nr = list.get_count()
    local line = null
    for(local j=0;j<l_nr;j++){
        line = list[j]
        if (line){
            local cov_nr = 0
            local cov_list = line.get_convoy_list()
 
            if (cov_list.get_count()!=0)
                continue
 
            local sch = line.get_schedule()
            local sch_nr = sch.entries.len()
            if (sch && sch_nr==0){
                line.destroy(player_x(pl))
            }
         
        }     
    }
    return null
}