mirror of
https://github.com/Ukendio/jecs.git
synced 2026-02-04 15:15:21 +00:00
44 lines
No EOL
792 B
Text
Executable file
44 lines
No EOL
792 B
Text
Executable file
-- original author @centau
|
|
|
|
local SUCCESS = true
|
|
local FAILURE = false
|
|
local RUNNING = newproxy(false)
|
|
|
|
local function SEQUENCE(nodes: { (...any) -> boolean})
|
|
return function(...)
|
|
for _, node in nodes do
|
|
local status = node(...)
|
|
if not status or status == RUNNING then
|
|
return status
|
|
end
|
|
end
|
|
return SUCCESS
|
|
end
|
|
end
|
|
|
|
local function FALLBACK(nodes: { (...any) -> boolean })
|
|
return function(...)
|
|
for _, node in nodes do
|
|
local status = node(...)
|
|
if status or status == RUNNING then
|
|
return status
|
|
end
|
|
end
|
|
return FAILURE
|
|
end
|
|
end
|
|
|
|
local function NOT(f)
|
|
return function(...): boolean
|
|
return not f(...)
|
|
end
|
|
end
|
|
|
|
local bt = {
|
|
SEQUENCE = SEQUENCE,
|
|
FALLBACK = FALLBACK,
|
|
RUNNING = RUNNING,
|
|
NOT = NOT,
|
|
}
|
|
|
|
return bt |