-
Notifications
You must be signed in to change notification settings - Fork 2
/
bt_exepath.lua
49 lines (39 loc) · 885 Bytes
/
bt_exepath.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
local exepath = {}
function exepath:init()
self:clear()
end
function exepath:clear()
self.path = {}
self.nodes = {}
end
function exepath:on_exe_node(bt, level, node)
local node_info = {
node = node,
args = {},
level = level,
}
if node.args then
for idx, v in ipairs(node.args) do
if type(v) == 'function' then
node_info.args[idx] = v(bt)
else
node_info.args[idx] = v
end
end
end
self.path[#self.path + 1] = node_info
self.nodes[node] = node_info
end
function exepath:on_node_status(bt, node, status)
local node_info = self.nodes[node]
if node_info then
node_info.status = status
end
end
local M = {}
function M.create()
local o = setmetatable({}, {__index = exepath})
o:init()
return o
end
return M