News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

[line_x] Remove lines

Started by Yona-TYT, July 24, 2017, 08:34:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT


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

Dwachs

Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on July 25, 2017, 07:08:01 AM
Please check r8274
For some reason the "delete()" function can not be used.  ???


Dwachs

#3
I see, 'delete' is a language keyword.. will fix tonight.

Edit: fixed in r8275, renamed to 'destroy'
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

#4
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:

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
}




Dwachs

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.

Yona-TYT

Quote from: Dwachs 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.


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

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

Dwachs

Quote from: Yona-TYT on July 28, 2017, 08:39:05 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 ?.

line.get_convoy_list().get_count()==0
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

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