--- /home/yonatyt/simu-git/simutrans-master/script/api/api_tiles.cc 2021-08-11 16:03:07.000000000 -0400 +++ /home/yonatyt/simu-git/files/api_tiles.cc 2021-08-18 18:46:55.028232000 -0400 @@ -15,6 +15,9 @@ #include "../../simworld.h" #include "../../boden/wasser.h" +#include "../../simconvoi.h" +#include "../../vehicle/vehicle.h" + namespace script_api { declare_enum_param(grund_t::flag_values, uint8, "flags"); declare_specialized_param(depot_t*, "t|x|y", "depot_x"); @@ -110,6 +113,24 @@ return list; } +vector_tpl const get_convoy_list(koord3d pos) +{ + static vector_tpl list; + list.clear(); + //Test + grund_t *gr = welt->lookup(pos); + for (uint8 n = gr->get_top(); n-- != 0;) { + obj_t *obj = gr->obj_bei(n); + convoihandle_t cnv; + if (vehicle_t* veh = dynamic_cast(obj)) { + cnv = veh->get_convoi()->self; + list.append(cnv); + } + } + return list; +} + + void export_tiles(HSQUIRRELVM vm) { /** @@ -283,6 +304,12 @@ /// Mark tile. register_method_fv(vm, &grund_t::set_flag, "mark", freevariable(grund_t::marked)); //@} + + /** + * @return convoy list by tile + */ + register_method(vm, &get_convoy_list, "get_convoys", true); + #ifdef SQAPI_DOC // document members /** * List to iterate through all objects on this tile. --- /home/yonatyt/simu-git/simutrans-master/script/api/squirrel_types_scenario.awk 2021-08-11 16:03:07.000000000 -0400 +++ /home/yonatyt/simu-git/files/squirrel_types_scenario.awk 2021-08-18 18:28:02.497203000 -0400 @@ -359,6 +359,7 @@ export_types["tile_x::is_marked"] = "bool()" export_types["tile_x::unmark"] = "void()" export_types["tile_x::mark"] = "void()" + export_types["tile_x::get_convoys"] = "array()" export_types["square_x::is_valid"] = "bool()" export_types["square_x::get_halt"] = "halt_x()" export_types["square_x::get_player_halt"] = "halt_x(player_x)"