Page 1 of 1

Function that returns # of objects of a specific ID or Type?

Posted: 08 May 2012, 19:31
by Shadow Wolf TJC
I'm trying to figure out how to program scripts to perform certain actions depending on how many of a certain object ID, like, say, Hardened Sensor Towers, are present within a certain area, like, say, the entire map. This would not only allow AIs to make more flexible, more situational, choices, but would also be useful in, say, allowing modders to increase the number of HQs that a player can have on the field at a time, AND allow them to disable the design screen and minimap whenever the player has no HQs on the map (as opposed to disabling them whenever one of their HQs is destroyed).

Re: Function that returns # of objects of a specific ID or T

Posted: 08 May 2012, 19:46
by NoQ
Scripting subforum?
in JS, use

Code: Select all

enumStruct(me,"A0CommandCenter").length

Re: Function that returns # of objects of a specific ID or T

Posted: 08 May 2012, 21:02
by Shadow Wolf TJC
Thanks. I'm now able to create scripts that can tell how many of a certain object are left. In fact, thanks to you, I was able to develop a new piece of code that would allow modders to increase the limit on how many HQs they can have on the map at any given time. See ticket 3465 for more information.

Re: Function that returns # of objects of a specific ID or T

Posted: 09 May 2012, 22:14
by aubergine