Index: script/api/api_map_objects.cc =================================================================== --- script/api/api_map_objects.cc (revision 10048) +++ script/api/api_map_objects.cc (working copy) @@ -31,6 +31,7 @@ // for depot tools #include "../../simconvoi.h" #include "../../simmenu.h" +#include "../../descriptor/building_desc.h" #include "../../descriptor/vehicle_desc.h" @@ -447,6 +448,31 @@ return v; } +vector_tpl const& get_tile_list( gebaeude_t *gb ) +{ + static vector_tpl list; + const koord3d pos = gb->get_pos(); + const building_tile_desc_t* tile = gb->get_tile(); + koord size = tile->get_desc()->get_size( tile->get_layout() ); + const koord pos0 = gb->get_pos().get_2d() - tile->get_offset(); // get origin + koord k; + + list.clear(); + // add all tiles + for( k.y = 0; k.y < size.y; k.y++ ) { + for( k.x = 0; k.x < size.x; k.x++ ) { + if( grund_t* gr = welt->lookup( pos+k ) ) { + if( gebaeude_t* const add_gb = obj_cast(gr->first_obj()) ) { + if( gb->is_same_building( add_gb ) ) { + list.append( add_gb->get_pos() ); + } + } + } + } + } + return list; +} + void export_map_objects(HSQUIRRELVM vm) { /** @@ -565,6 +591,10 @@ */ register_method(vm, &gebaeude_t::get_tile, "get_desc"); /** + * @returns coord for all tiles + */ + register_method( vm, &get_tile_list, "get_tile_list" ); + /** * @returns true if both building tiles are part of one (multi-tile) building */ register_method(vm, &gebaeude_t::is_same_building, "is_same_building"); --- script/api/squirrel_types_scenario.awk (revision 10048) +++ script/api/squirrel_types_scenario.awk (working copy) @@ -234,6 +234,7 @@ export_types["building_x::get_mail_level"] = "integer()" export_types["building_x::get_desc"] = "building_desc_x()" export_types["building_x::is_same_building"] = "bool(building_x)" + export_types["building_x::get_tile_list"] = "array()" export_types["depot_x::append_vehicle"] = "void(player_x, convoy_x, vehicle_desc_x)" export_types["depot_x::start_convoy"] = "void(player_x, convoy_x)" export_types["depot_x::start_all_convoys"] = "void(player_x)"