Passing custom objects through finder functions don't get filtered
-
To reproduce:
// Before executing code below: get a creep you own // Using FIND_* constants // Returns nothing (to be exactly, it returns null and says hai twice) Game.creeps[Object.keys(Game.creeps)[0]].pos.findClosest(FIND_MY_CREEPS, {filter: function(e) {console.log('hai'); return false;}}); // Using custom objects // Returns the creep object and doesn't even say hai! Game.creeps[Object.keys(Game.creeps)[0]].pos.findClosest([Game.creeps[Object.keys(Game.creeps)[0]]], {filter: function(e) {console.log('hai'); return false;}});
Also pasted this on http://pastebin.com/vUdkYEPy
-
Sounds like documentation issue, with the thought being that the supplied list of objects is already filtered.
On the topic of filtering, is the server-side component capable of array comprehension? Like so:
»Game.creeps[Object.keys(Game.creeps)[0]].pos.findClosest([Game.creeps[Object.keys(Game.creeps)[0]]], {filter: function(e) {console.log('hai'); return false;}}); « [creep Eva] »Game.creeps[Object.keys(Game.creeps)[0]].pos.findClosest([for (creep of Object.keys(Game.creeps)) if (creep !== Object.keys(Game.creeps)[0]) Game.creeps[creep]], {filter: function(e) {console.log('hai'); return false;}}); «[creep Julia]
-
At least I did got in a situation I swapped the
FIND_
constant with objects, this can be unwanted behavior.