Jump to content
karver

Finding all of one type of building.

Recommended Posts

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

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

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... :/

  • Like 1

Share this post


Link to post
Share on other sites

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
  • Like 2

Share this post


Link to post
Share on other sites

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.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×