mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 02:12:42 -04:00
Added runlevel information, mainly to allow rc scripts to tell if they're run during startup (where primaries may not be set, yet, so they'll have to wait for the init event) or not.
This commit is contained in:
parent
c31b74f811
commit
aa55f1fc1d
@ -9,5 +9,6 @@ function start(msg)
|
||||
print(msg)
|
||||
end
|
||||
print(count)
|
||||
print("runlevel: " .. require("computer").runlevel())
|
||||
count = count + 1
|
||||
end
|
||||
|
@ -5,6 +5,18 @@ do
|
||||
local computer = computer
|
||||
local unicode = unicode
|
||||
|
||||
-- Runlevel information.
|
||||
local runlevel, shutdown = "S", computer.shutdown
|
||||
computer.runlevel = function() return runlevel end
|
||||
computer.shutdown = function(reboot)
|
||||
runlevel = reboot and 6 or 0
|
||||
if os.sleep then
|
||||
computer.pushSignal("shutdown")
|
||||
os.sleep(0.1) -- Allow shutdown processing.
|
||||
end
|
||||
shutdown(reboot)
|
||||
end
|
||||
|
||||
-- Low level dofile implementation to read filesystem libraries.
|
||||
local rom = {}
|
||||
function rom.invoke(method, ...)
|
||||
@ -151,10 +163,9 @@ do
|
||||
computer.pushSignal("init") -- so libs know components are initialized.
|
||||
|
||||
status("Initializing system...")
|
||||
os.sleep(0.1)
|
||||
|
||||
require("term").clear()
|
||||
os.sleep(0.1) -- Allow init processing.
|
||||
runlevel = 1
|
||||
end
|
||||
|
||||
local function motd()
|
||||
|
@ -1241,7 +1241,7 @@ local libcomputer = {
|
||||
end,
|
||||
|
||||
shutdown = function(reboot)
|
||||
coroutine.yield(reboot ~= nil and reboot ~= false)
|
||||
coroutine.yield(not not reboot)
|
||||
end,
|
||||
pushSignal = function(...)
|
||||
return spcall(computer.pushSignal, ...)
|
||||
|
Loading…
x
Reference in New Issue
Block a user