Skip to content

Fix registry instances#12

Draft
s-kania wants to merge 1 commit intotanema:masterfrom
s-kania:fix-registry-instances
Draft

Fix registry instances#12
s-kania wants to merge 1 commit intotanema:masterfrom
s-kania:fix-registry-instances

Conversation

@s-kania
Copy link

@s-kania s-kania commented Jun 23, 2023

This is my draft proposal to fix #8.
What I changed?

  • instead of creating a new instance of a node that is then added to the registry and used in multiple trees, the user now creates templates,
  • when the user requests a node from the registry, a new instance is created, but with function references from template -> start, finish, run
  • if we run the tree again that uses registered nodes, it will use the previously created

Example:

local templates = {
  sail_to = {
      type = BehaviourTree.Task,
      run = function(task, ship_id)
         [code]
      end
  },
  sink_ship = {
      type = BehaviourTree.Sequence,
      nodes = {
          'sail_to',
          {
	      type = BehaviourTree.Task,
	      run = function(task, ship_id)
                  [code]
	      end
          },
      },
  },
}
BehaviourTree.register(templates)

@tanema
Copy link
Owner

tanema commented Jun 26, 2023

Okay this all looks like it makes sense and is a good looking changeset. Can you add some unit tests to ensure that it does what is expected and will not break in the future?

@tanema
Copy link
Owner

tanema commented Jun 26, 2023

Please rebase, I updated the testing for PRs from travis to github actions so that you can get automated feedback on your work.

@s-kania
Copy link
Author

s-kania commented Jun 28, 2023

Okay this all looks like it makes sense and is a good looking changeset. Can you add some unit tests to ensure that it does what is expected and will not break in the future?

Yes, I will add tests and check if everything is OK.

@s-kania
Copy link
Author

s-kania commented Jul 18, 2024

Sorry, I will probably never update this. But I created my own implementation forked from your library. It's for Defold engine, but it's still LUA. So if somebody is interested it's available here-> https://github.com/s-kania/def-behavior-tree

@timjen3 timjen3 mentioned this pull request Sep 6, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple instances with same task name used in BT

2 participants