blob: f1cd2457c450903a89b31658ad280f0f77ff05c3 (
plain)
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
|
-- Small helper to organize code for the same context into different Lua scripts without having to "hook" previously defined.
modules = setmetatable({}, {__call = function(this, path, names)
for i, name in pairs(names) do
require(path .. name .. ".lua")
end
end})
local modules, type = modules, type
local function call(func, ...)
if type(func) == "function" then
return func(...)
end
end
function init(...)
script.setUpdateDelta(1)
for i, module in pairs(modules) do
call(module.init, ...)
end
end
function update(...)
for i, module in pairs(modules) do
call(module.update, ...)
end
end
function uninit(...)
for i, module in pairs(modules) do
call(module.uninit, ...)
end
end
|