View Single Post
  #3  
Old 03-17-2010, 11:16 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
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=0i<args[0]; i++)
  {
    
// Call the node, and quit looping if it fails (returns false)
    
if (!callInner(func))
      return 
false;
  }
  return 
true;

__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote