Skip to content

Commit f227a11

Browse files
committed
update
1 parent 316d539 commit f227a11

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/node_modules/
22
/package-lock.json
3+
/.docusaurus/

versioned_docs/version-3.8/tutorial-basics/tutorial_08_additional_args.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,23 @@ private:
6363
};
6464
```
6565

66-
Registering this node and passing the known arguments is as easy as:
66+
To register this node and passing the known arguments:
6767

6868
``` cpp
6969
BT::BehaviorTreeFactory factory;
70-
factory.registerBuilder<Action_A>("Action_A", 42, "hello world");
7170

72-
// If you prefer to specify the template parameters
73-
// factory.registerBuilder<Action_A, int , std::string>("Action_A", 42, "hello world");
71+
// A node builder is a functor that creates a std::unique_ptr<TreeNode>.
72+
// Using lambdas or std::bind, we can easily "inject" additional arguments.
73+
BT::NodeBuilder builder_A =
74+
[](const std::string& name, const NodeConfiguration& config)
75+
{
76+
return std::make_unique<Action_A>( name, config, 42, "hello world" );
77+
};
78+
79+
// BehaviorTreeFactory::registerBuilder is a more general way to
80+
// register a custom node.
81+
factory.registerBuilder<Action_A>( "Action_A", builder_A);
82+
7483
```
7584

7685
## Use an "initialize" method

0 commit comments

Comments
 (0)