Giter VIP home page Giter VIP logo

Comments (4)

Calamari avatar Calamari commented on August 18, 2024

Hi @sunq0001.

I am not quite sure if I get the question.
The first line describes how to import the InvertDecorator class into your code and the second snippet describes how to write a new one, if you would want to create one.

If you want to simply use decorators that are already written, then you can do this for example (that's how the README.md states):

const decoratedSequence = new InvertDecorator({
  node: 'awesome sequence doing stuff'
})

which needs some node (in that contrived example probably a sequence) registered. Maybe like this:

BehaviorTree.register('test sequence', mySequence)

Another example how to use it, you can also find within the spec-files. Take a look at src/decorators/InvertDecorator.spec.js for example. (There you can also see that 'awesome sequence doing stuff' can just be a previously instantiated node as well.)

Does this help?

from behaviortree.js.

sunq0001 avatar sunq0001 commented on August 18, 2024

@Calamari
thanks for your reply.
i just found that i cannot require the decorators in a directly way
const {InvertDecorator} = require('behaviortree');
console.log(InverDecorator) //undefined
but anyway, i found i can use BehaviorTreeImporter to import decorators, this consider the problem is solved.
thanks a lot man.

from behaviortree.js.

Calamari avatar Calamari commented on August 18, 2024

Soooo … @sunq0001

Now I understood the core problem, and have to admit, you are right, there was no easy way to load the built-in decorators. 🤦
But I added those exports in v2.0.3 now. And mentioned those in the README.

I hope it helps and it is easier now.

from behaviortree.js.

crapthings avatar crapthings commented on August 18, 2024

how to wrap a node with a decorator?
any example

const decoratedSequence = new InvertDecorator({
  node: 'awesome sequence doing stuff'
  run: function (somethingToCheck) {
   return SUCCESS
  }
})

from behaviortree.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.