Open gsommavilla opened 6 years ago
i know this is late, but for anyone else, that's a static property feature that's supported in this project through babel: https://babeljs.io/docs/en/babel-plugin-proposal-class-properties
you can fix this by setting it in the constructor, like:
import { Decorator, RUNNING, SUCCESS, FAILURE } from "behaviortree";
export class InvertDecorator extends Decorator {
constructor(props) {
super(props);
this.nodeType = "InvertDecorator";
}
decorate(run) {
const result = run();
if (result === RUNNING) return RUNNING;
return result === SUCCESS ? FAILURE : SUCCESS;
}
}
(and be sure to pass props
along to super
)
I have an issue while trying to create a custom decorator.
I have tried a MWE using a decorator that is already present in the library, namely
CooldownDecorator
, and it works just fine.But when I try to build a custom decorator, problems arise.
I created the following decorator:
Which is very similar to the test
src/BehaviorTreeImporter.spec.js
that is present in the library of the behaviortree module.The class
IsBallNearDecorator
is imported into a minimal behaviortree, like this:When trying to execute the tree, I get the following error:
I am not sure if
nodeType
is mandatory, so I tried to comment it out (// nodeType = 'IsBallNearDecorator';
), but then I get another error:I also tried invoking
node
instead ofbabel-node
(replacingimport
withrequire(..)
,export default
withmodule.exports
, ..), but the result is the same error.I tried to modify the behaviortree library, but I haven't been able to get webpack compile the source code.
Can anyone help me with this issue?