The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on January 30, 2021, 01:48:24 AM

Title: Vehicles in the depot seem to ignore "is_in_depot ()"
Post by: Yona-TYT on January 30, 2021, 01:48:24 AM
In the tutorial scenario I found a problem when counting vehicles outside the depot, something seems to have broken when the schedule window was updated. https://forum.simutrans.com/index.php/topic,20444.msg194610/topicseen.html#msg194610 (https://forum.simutrans.com/index.php/topic,20444.msg194610/topicseen.html#msg194610)

It seems to be related to "is_work_allowed_here (pl, tool_id, pos)", since this happens when said function returns a message while editing the schedule.

This is how I count the vehicles:function checks_all_convoys()
{
    local cov_list = world.get_convoy_list()
    local cov_nr = 0
    foreach(cov in cov_list) {
        if (!cov.is_in_depot())
            cov_nr++
       
    }   
    return cov_nr
}

To recreate use my attached test script and follow the steps below:
Note: I have left a vehicle counter in the scenario window right in the results.
Title: Re: Vehicles in the depot seem to ignore "is_in_depot ()"
Post by: Andarix on January 30, 2021, 09:22:28 AM
world.get_convoy_list_x()
http://dwachs.github.io/simutrans-sqapi-doc/classconvoy__list__x.html (http://dwachs.github.io/simutrans-sqapi-doc/classconvoy__list__x.html)

mmh

world.get_convoy_list()
http://dwachs.github.io/simutrans-sqapi-doc/classworld.html#a68633926c5c89aee2ab4f5e4a77e8fe5 (http://dwachs.github.io/simutrans-sqapi-doc/classworld.html#a68633926c5c89aee2ab4f5e4a77e8fe5)
Title: Re: Vehicles in the depot seem to ignore "is_in_depot ()"
Post by: Dwachs on January 31, 2021, 10:10:48 AM
This has nothing to do with the script. Thanks for your report.