karver 10 Posted October 22, 2015 I'm playing on Bornholm and was wondering if there was a way for me to find all of one type of building. Specifically the large green military towers. Also hospitals, but j think there's only one of those in the map. Share this post Link to post Share on other sites
Ranwer135 308 Posted October 22, 2015 nearestObjects. Place this in your unit's init: player addAction ["Retrieve nearest Building", {nearBuilding = typeOf (nearestBuilding player); hint format ["%1", nearBuilding]}]; Every time you click the custom action above, it will display the type of the closest building. Hope it helps, Rawner135 Share this post Link to post Share on other sites
haleks 8206 Posted October 22, 2015 I think what Karver wants is a function able to list all buildings of a certain type as well as their positions on a terrain. Obviously you can't iterate through all buildings on the map (I know, I tried) as it would crash the game; but there must be another way : look at Alive mod. I don't know how they do it though... :/ 1 Share this post Link to post Share on other sites
Greenfist 1863 Posted October 22, 2015 I think what Karver wants is a function able to list all buildings of a certain type as well as their positions on a terrain. Obviously you can't iterate through all buildings on the map (I know, I tried) as it would crash the game; but there must be another way : look at Alive mod. I don't know how they do it though... :/ You don't have to iterate through all buildings. Just the ones you need. You could find the class name with Ranwer135's suggestion or by typing "typeof cursorTarget" to console's watch line and copying the name from there. And then: buildings = nearestObjects [[0,0,0], ["the_classname"], 50000]; //object array positions = []; {positions pushback (getpos _x)} foreach buildings; //positions array 2 Share this post Link to post Share on other sites
haleks 8206 Posted October 22, 2015 buildings = nearestObjects [[0,0,0], ["the_classname"], 50000]; //object array positions = []; {positions pushback (getpos _x)} foreach buildings; //positions array Word of advice : don't use hint str(positions) to visualize the result, very long hint messages can drop your framerate to a single digit - that's probably what was causing the crashes in my case... Use CopytoClipBoard str(positions) to retrieve the array. 1 Share this post Link to post Share on other sites