Extending It's Usage
You may want to create new Node Decorators for your behavior trees. This is a bit more complicated than the rest of the behavior tree usage due to the fact that node decorators have to be dynamically nested while allowing an argument.
There are two important things you need to know. First off, decorator functions take one argument: the next function to be called. The actual argument to a node decorator (as specified in it's declaration, such as how many times to loop, what variable to filter, etc) is held in a dict (associative array) called this.decorators. To get this argument you use 'this.decorators.get("functionName");'. Second, in order to continue execution (calling either the next node decorator or the node function) you need to call 'callInner(func);' where func is the function argument to the decorator.
Here is an example (from the default loop function):
PHP Code:
function loop(func)
{
// Get the loop arguments
temp.args = this.decorators.get("loop");
// Loop execution based on the argument
for (temp.i=0; i<args[0]; i++)
{
// Call the node, and quit looping if it fails (returns false)
if (!callInner(func))
return false;
}
return true;
}