-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinvert.lua
More file actions
39 lines (33 loc) · 783 Bytes
/
invert.lua
File metadata and controls
39 lines (33 loc) · 783 Bytes
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
local Const = require "const"
local BTCommon = require "bt_common"
local mt = {}
mt.__index = mt
function mt:run(tick, data)
local status = BTCommon.execute(self.child, tick, data.__level + 1)
if status == Const.RUNNING then
return status
elseif status == Const.SUCCESS then
return Const.FAIL
else
return Const.SUCCESS
end
end
function mt:close(tick)
local node = self.child
local node_data = tick[node]
if node_data and node_data.is_open then
node_data.is_open = false
if node.close then
node:close(tick, node_data)
end
end
end
local function new(node)
local obj = {
name = "invert",
child = node,
}
setmetatable(obj, mt)
return obj
end
return new