Giter Club home page Giter Club logo

Comments (7)

Wokarol avatar Wokarol commented on July 23, 2024

Update: I found out you can "Label" nodes. What about adding extension method or member method to node like

new Selector(...).Labeled("Steering");

or "fake decorator" like

NPBehave.Labeled("Steering", new Selector(...));

Probably best solution would be to add this directly in the constructor like so

new Selector("Steering", ...);

But that would require a lot of changes

from npbehave.

meniku avatar meniku commented on July 23, 2024

Hey, so the intended syntax for the labelling is quite similar to your first idea
new Selector(...).Labeled("Steering");

it goes like this:

new Selector(
...
 ) { Label = "Follow" }

adding your idea wouldn't be much work, but maybe you can work already with the syntax we have?

from npbehave.

Wokarol avatar Wokarol commented on July 23, 2024

Checked it briefly, it's fine but "Fake Decorator" would be still a little better due to information flow. Because then you have label next to actual node definition and not after this.
This could be added as a simple Utility Method, I might try doing it later.

from npbehave.

meniku avatar meniku commented on July 23, 2024

OK. We can maybe also go for the one to include it in the constructor, but it will increase amount of mandatory fields. I would like to keep it optional if possible...

With 2.0 I'll probably have to rethink the way we handle growing amounts of fields in the constructors. Not sure if there is any better way to describe the trees by Code. But I would like to also reduce the amount of constructors if possible.

Maybe we could prefer using named parameters somehow, but I'm not sure if it works with the composites so well. Maybe we could live with something like

new Selector( label: "Follow", children: [
...
] ),

from npbehave.

Wokarol avatar Wokarol commented on July 23, 2024

Actual utility method would look more or less like this now that I look at it:

public static class NPBehaveUtils
{
  public static Node Label(string label, Node node)
  {
    node.Label = label;
    return node;
  }
}

Now, you can just add using static NPBehaveUtils on top of the script and done

Label("Steering", new Selector(
  ...
));

from npbehave.

Wokarol avatar Wokarol commented on July 23, 2024

I also think, after second thought that it would be the best solution due to it being universal for every Node

from npbehave.

meniku avatar meniku commented on July 23, 2024

right. Let's keep it simple for now. For 2.0 we can rethink this

from npbehave.

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.