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

For code related discussions and questions

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

Postby Shadow Wolf TJC » 08 May 2012, 18:31

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
Shadow Wolf TJC
Professional

User avatar
 
Joined: 16 Apr 2011, 04:12
Location: Raleigh, NC

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

Postby NoQ » 08 May 2012, 18:46

Scripting subforum?
in JS, use
Code: Select all
enumStruct(me,"A0CommandCenter").length
NoQ
Hero

User avatar
 
Joined: 24 Dec 2009, 10:35
Location: /var/zone

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

Postby Shadow Wolf TJC » 08 May 2012, 20:02

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
Shadow Wolf TJC
Professional

User avatar
 
Joined: 16 Apr 2011, 04:12
Location: Raleigh, NC

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

Postby aubergine » 09 May 2012, 21:14

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

User avatar
 
Joined: 09 Oct 2010, 23:58


Return to Coding

Who is online

Users browsing this forum: No registered users and 2 guests