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:
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:
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
}
}
}
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.
I noticed that when copying several vehicles, and then selling one of them, the correct result appears.