Re: 3.2 JS API Wishlist :)
Posted: 09 Dec 2012, 12:33
listDroid(), listStruct(), listFeature() functions
They'd take same params as their enum() counterparts, but instead of returning full game objects they'd just return simplified objects.
A simplified object would be:
* id
* type
* name (for feature objects) / droidType (for droid objects) / stattype (for structure and certain feature objects)
* x, y, z
* health
* armed (if applicable)
* order (if applicable)
* selected (if applicable)
Why these functions? Increasingly, scripts are wanting to cache objects and define extra properties on the cached objects. A set of functions that return much less information will allow crucial information to be updated on a more regular basis, with more detailed updates being done only on an as-needed basis.
For example, I might have a cache of my own droids. When droids are built I add to the list, when they are destroyed/transferred/recycled I remove from the list. I'd want to get updated info on their location, health and order quite frequently, but all the other info (such as armour, born, turrets, etc) doesn't change much, if at all, and would only be retrieved on an as-needed basis (and even then probably in batches of a few droids at a time).
In many cases, I don't need all the other info, even when listing enemy droids, it seems wasteful to have the JS API generate a large number of properties when I only want basic information.
They'd take same params as their enum() counterparts, but instead of returning full game objects they'd just return simplified objects.
A simplified object would be:
* id
* type
* name (for feature objects) / droidType (for droid objects) / stattype (for structure and certain feature objects)
* x, y, z
* health
* armed (if applicable)
* order (if applicable)
* selected (if applicable)
Why these functions? Increasingly, scripts are wanting to cache objects and define extra properties on the cached objects. A set of functions that return much less information will allow crucial information to be updated on a more regular basis, with more detailed updates being done only on an as-needed basis.
For example, I might have a cache of my own droids. When droids are built I add to the list, when they are destroyed/transferred/recycled I remove from the list. I'd want to get updated info on their location, health and order quite frequently, but all the other info (such as armour, born, turrets, etc) doesn't change much, if at all, and would only be retrieved on an as-needed basis (and even then probably in batches of a few droids at a time).
In many cases, I don't need all the other info, even when listing enemy droids, it seems wasteful to have the JS API generate a large number of properties when I only want basic information.