Posted 20 May 2013 - 03:22 PM
Problems with the code:
in the "mainframe" program, it should wait for a key press event, and respond to that, however, as soon as it has printed the lines it should in "frame()", it exits all programs into the craftOS shell.
The program structure is as follows:
-Advanced computer
–"startup"
-Disk drive(connected to the advanced computer)
–Floppy disk
—"mainframe"
I recommend reading the code here, since its formatted better and easier to read: http://lua.paste.to/MjYxODQ=
in the "mainframe" program, it should wait for a key press event, and respond to that, however, as soon as it has printed the lines it should in "frame()", it exits all programs into the craftOS shell.
The program structure is as follows:
-Advanced computer
–"startup"
-Disk drive(connected to the advanced computer)
–Floppy disk
—"mainframe"
I recommend reading the code here, since its formatted better and easier to read: http://lua.paste.to/MjYxODQ=
--advanced computer/startup:
term.setTextColor(colors.lime)
modem = peripheral.wrap("top")
pumps = false
this = {}
this.id = os.getComputerID()
this.version = os.version()
this.day = os.day()
this.time = os.time()
this.running = false
this.hasDisk = function()
if disk.isPresent("bottom") then
if disk.hasData("bottom") then
return true
else
return false
end
else
return false
end
end
this.asd = 0
function kernelpanic(id, thread)
term.setBackgroundColor(colors.blue)
term.setTextColor(colors.white)
coroutine.yield(thread)
clear()
mbinfo()
write(id.."\n\n")
write("STOP ERROR 0x000002\n\n")
write("Press any key to shut down")
os.pullEvent("char")
os.shutdown()
end
function clear()
term.clear()
term.setCursorPos(1,1)
end
function mbinfo()
write("Absolute Zero Corporation (c) 1953-2013\n\n\n")
end
function info()
clear()
write("Rocket OS - Absolute Zero Corporation (c) 2013\n\n\n")
end
function main()
if this.hasDisk() then
if not this.running then
clear()
mbinfo()
print("Boot device connected.")
sleep(1)
clear()
mbinfo()
print("Running Floppy in 'Disk Drive 0'")
sleep(3)
clear()
mbinfo()
print("Running disk/mainframe")
sleep(1.6)
clear()
mainframeThread = coroutine.resume(coroutine.create(function()
shell.run("disk/mainframe")
end))
this.running = true
sleep(1)
main()
end
else
if not this.running then
clear()
mbinfo()
print("Insert a boot device")
sleep(3)
main()
else
kernelpanic("disk/ is nil!", mainframeThread)
end
end
end
main()
--disk/mainframe:
function frame()
info()
print("[1] - Launch pad control")
print("[2] - Oxygen control")
print("[3] - Bioreactor control")
print("[4] - Reboot the mainframe")
local _,k = os.pullEvent("char")
if k == "1" then
info()
if not pumps then
print("[1] - Enable fuel pumps")
--modem.transmit("launchpad_fuelcontrol_pumps_enable")
else
print("[1] - Disable fuel pumps")
end
print("[2] - Back")
local _,k2 = os.pullEvent("char")
if k2 == "1" then
if not pumps then
modem.transmit("launchpad_fuelcontrol_pumps_enable")
else
modem.transmit("launchpad_fuelcontrol_pumps_disable")
end
elseif k2 == "2" then
frame()
end
elseif k == "2" then
frame()
elseif k == "3" then
frame()
elseif k == "4" then
clear()
write("Rebooting...")
sleep(2)
os.reboot()
end
end
frame()