Skip to content

Arguments to node instances #10

@rubenwardy

Description

@rubenwardy

I'd like to provide arguments to an instance of a task. Currently, I do that by creating an entire new node type:

local function create_action_task(params)
	return BehaviourTree.Task:new({
		run = function(self, entity)
			local action = entity:set_action_if_not_set(unpack(params))
			if action:is_complete() then
				self:success()
			else
				self:running()
			end
		end,
	})
end

local bt = BehaviourTree:new({
	tree = BehaviourTree.Sequence:new({
		nodes = {
			create_action_task({ rvwp.entity.actions.go_to, Vector:new(4, 5, 0) }),
			create_action_task({ rvwp.entity.actions.go_to, Vector:new(16, 5, 1) }),
		}
	})
})

bt:setObject(entity)

is there a better way to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions