Author Topic: Problems with "halt_x (). Is_connected (halt, good_desc_x ())"  (Read 360 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT


I am using "is_connected" to determine if the "halt of schedule" is connected for vehicles within the deposit.

The problem is that when assigned a line, this does not work (apparently).
example:
Code: [Select]
        local halta = this.my_tile(coord).get_halt()    //Halt de la estacion
        local cov_list = depot.get_convoy_list()        //Lista de vehiculos en el deposito
        local cov_nr = 0                                //Contador de vehiculos
        foreach(cov in cov_list) {
            local line = cov.get_line()
            if (line){
                local sch = line.get_schedule()
                if (sch){
                    local nr = sch.entries.len()
                    for(local j=0;j<nr;j++) {
                        //if (cov_nr==max)
                            //return cov_nr
                        local haltb = sch.entries[j].get_halt(player_x(pl))        //Halt de la estacion asociada al vehiculo
                        if (halta.is_connected(haltb, good_desc_x(good))){
                            if (j==nr-1)
                                cov_nr++
                            continue
                        }
                        else
                            break
                    }
                }               
            }
        }


This works well when the vehicle is not assigned a line.
example:
Code: [Select]
        local halta = this.my_tile(coord).get_halt()    //Halt de la estacion
        local cov_list = depot.get_convoy_list()        //Lista de vehiculos en el deposito
        local cov_nr = 0                                //Contador de vehiculos
        foreach(cov in cov_list) {
            local sch = cov.get_schedule()
            if (sch){
                local nr = sch.entries.len()
                for(local j=0;j<nr;j++) {
                    //if (cov_nr==max)
                        //return cov_nr
                    local haltb = sch.entries[j].get_halt(player_x(pl))        //Halt de la estacion asociada al vehiculo
                    if (halta.is_connected(haltb, good_desc_x(good))){
                        if (j==nr-1)
                            cov_nr++
                        continue
                    }
                    else
                        break
                }
            }
        }

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4251
  • Total likes: 177
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Problems with "halt_x (). Is_connected (halt, good_desc_x ())"
« Reply #1 on: May 10, 2017, 08:53:31 AM »
The program caches the connections of halts.  halt.is_connected returns this cached value. It may take some time until the cache is up-to-date after changes to schedules/lines/convoys. Hence it may happen that
is_connected returns -1, which means the cache is invalidated, and you have to call this method again (later) to get a reliable result. There are no updates during paused games.

Two halts are connected if there are convoys (or lines with convoys) connecting the halts.

I suspect that the problem you described is due to (1) pause mode or (2) lines without convoys. Still have to test it myself.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Problems with "halt_x (). Is_connected (halt, good_desc_x ())"
« Reply #2 on: May 10, 2017, 11:34:38 AM »
I noticed that when copying several vehicles, and then selling one of them, the correct result appears.