mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-13 09:18:05 -04:00
parent
abe18ad535
commit
aae7029dbe
@ -38,9 +38,11 @@ local function load(name, args)
|
||||
if result then
|
||||
rc.loaded[name] = env
|
||||
return env
|
||||
else
|
||||
return nil, string.format("%s failed to start: %s", fileName, reason)
|
||||
end
|
||||
end
|
||||
return nil, reason
|
||||
return nil, string.format("%s failed to load: %s", fileName, reason)
|
||||
end
|
||||
|
||||
function rc.unload(name)
|
||||
@ -116,24 +118,33 @@ local function allRunCommand(cmd, ...)
|
||||
return results
|
||||
end
|
||||
|
||||
local stream = io.stderr
|
||||
local write = stream.write
|
||||
|
||||
if select("#", ...) == 0 then
|
||||
local results,reason = allRunCommand("start")
|
||||
-- if called during boot, pipe errors to onError handler
|
||||
if _G.runlevel == "S" then
|
||||
write = function(_, msg)
|
||||
require("event").onError(msg)
|
||||
end
|
||||
end
|
||||
|
||||
local results, reason = allRunCommand("start")
|
||||
if not results then
|
||||
local msg = "rc failed to start:"..tostring(reason)
|
||||
io.stderr:write(msg)
|
||||
require("event").onError(msg)
|
||||
write(stream, msg, "\n")
|
||||
return
|
||||
end
|
||||
for _, result in pairs(results) do
|
||||
local ok, reason = table.unpack(result)
|
||||
if not ok then
|
||||
io.stderr:write(reason, "\n")
|
||||
write(stream, reason, "\n")
|
||||
end
|
||||
end
|
||||
else
|
||||
local result, reason = runCommand(...)
|
||||
if not result then
|
||||
io.stderr:write(reason, "\n")
|
||||
write(stream, reason, "\n")
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
@ -8,10 +8,11 @@ local computer = computer
|
||||
local unicode = unicode
|
||||
|
||||
-- Runlevel information.
|
||||
local runlevel, shutdown = "S", computer.shutdown
|
||||
computer.runlevel = function() return runlevel end
|
||||
_G.runlevel = "S"
|
||||
local shutdown = computer.shutdown
|
||||
computer.runlevel = function() return _G.runlevel end
|
||||
computer.shutdown = function(reboot)
|
||||
runlevel = reboot and 6 or 0
|
||||
_G.runlevel = reboot and 6 or 0
|
||||
if os.sleep then
|
||||
computer.pushSignal("shutdown")
|
||||
os.sleep(0.1) -- Allow shutdown processing.
|
||||
|
Loading…
x
Reference in New Issue
Block a user