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

For code related discussions and questions
Post Reply
User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

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

Post 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).
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

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

Post by NoQ »

Scripting subforum?
in JS, use

Code: Select all

enumStruct(me,"A0CommandCenter").length
User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

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

Post 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.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

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

Post by aubergine »

"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Post Reply