2016-01-07 02:58:05 +11:00
|
|
|
function checkArg(n, have, ...)
|
2016-01-06 08:29:49 +11:00
|
|
|
have = type(have)
|
|
|
|
local function check(want, ...)
|
|
|
|
if not want then
|
|
|
|
return false
|
|
|
|
else
|
|
|
|
return have == want or check(...)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if not check(...) then
|
|
|
|
local msg = string.format("bad argument #%d (%s expected, got %s)",
|
|
|
|
n, table.concat({...}, " or "), have)
|
|
|
|
error(msg, 3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
2016-01-05 04:20:40 +11:00
|
|
|
print("LuPI L1 INIT")
|
|
|
|
modules = {}
|
|
|
|
|
|
|
|
local function loadModule(name)
|
|
|
|
print("LuPI L1 INIT > Load module > " .. name)
|
|
|
|
--TODO: PRERELEASE: Module sandboxing, preferably secure-ish
|
|
|
|
--TODO: ASAP: Handle load errors
|
|
|
|
if not moduleCode[name] then
|
|
|
|
error("No code for module " .. tostring(name))
|
|
|
|
end
|
2016-01-06 08:29:49 +11:00
|
|
|
local code, reason = load(moduleCode[name])
|
|
|
|
if not code then
|
|
|
|
print("Failed loading module " .. name .. ": " .. reason)
|
|
|
|
else
|
|
|
|
modules[name] = code()
|
|
|
|
end
|
2016-01-05 04:20:40 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
--Load modules
|
|
|
|
loadModule("random")
|
2016-01-07 02:58:05 +11:00
|
|
|
loadModule("color")
|
|
|
|
|
2016-01-05 04:20:40 +11:00
|
|
|
loadModule("component")
|
|
|
|
loadModule("computer")
|
2016-01-07 02:58:05 +11:00
|
|
|
|
|
|
|
loadModule("textgpu")
|
|
|
|
|
2016-01-05 04:20:40 +11:00
|
|
|
loadModule("sandbox")
|
|
|
|
loadModule("boot")
|
|
|
|
|
|
|
|
--Setup core modules
|
|
|
|
modules.component.prepare()
|
2016-01-06 08:29:49 +11:00
|
|
|
modules.computer.prepare()
|
2016-01-05 04:20:40 +11:00
|
|
|
|
2016-01-07 02:58:05 +11:00
|
|
|
modules.textgpu.start()
|
2016-01-05 04:20:40 +11:00
|
|
|
modules.boot.boot()
|