Posted 07 January 2013 - 10:34 AM
I'm creating a boot loader for my OS, but i'm having problems… He have a countdown, but when the count Reaches 0, the boot loader doesn't stop… If i press any key that i'm using in the boot loader (arrows), the boot loader restart and reboot the os… So i have to stop him! And i don't know how do this… And when i select another item, the boot loader start a new count, and don't stop the old…
Here's the code:
Some one can help me?
Here's the code:
Spoiler
--Made by Oct125 for Util OS
selection = 1
term.clear()
term.setCursorPos(1,1)
print(" Boot Loader ")
print(" ")
print(" +---------------------------------------+ ")
print(" | | ")
print(" | | ")
print(" | | ")
print(" | | ")
print(" | | ")
print(" | | ")
print(" | | ")
print(" | | ")
print(" | | ")
print(" +---------------------------------------+ ")
print(" | | ")
print(" | | ")
print(" +---------------------------------------+ ")
function timer()
term.setCursorPos(6,14)
print("Starting in: 4")
sleep(1)
term.setCursorPos(6,14)
print("Starting in: 3")
sleep(1)
term.setCursorPos(6,14)
print("Starting in: 2")
sleep(1)
term.setCursorPos(6,14)
print("Starting in: 1")
sleep(1)
term.setCursorPos(6,14)
term.clearLine(6,14)
print("BOOTING...")
if selection == 1 then
shell.run(".Util/os") -- boot the OS
return
else
term.clear()
term.setCursorPos(1,1)
shell.run("shell") -- boot default shell
return
end
end
function text()
if selection == 1 then -- Util OS
term.setCursorPos(6,4)
term.setBackgroundColor(colors.lightGray)
write(" ")
term.setCursorPos(6,4)
write("Util OS 0.1 BETA")
term.setCursorPos(6,5)
term.setBackgroundColor(colors.black)
write(os.version())
else -- CraftOS
term.setCursorPos(6,4)
term.setBackgroundColor(colors.black)
write(" ")
term.setCursorPos(6,4)
write("Util OS 0.1 BETA")
term.setCursorPos(6,5)
term.setBackgroundColor(colors.lightGray)
write(" ")
term.setCursorPos(6,5)
write(os.version())
term.setBackgroundColor(colors.black)
end
parallel.waitForAny(
function()
local sEvent, param = os.pullEvent("key")
if sEvent == "key" then
if param == 208 then
selection = 2
text()
elseif param == 200 then
selection = 1
tempo = 4
text()
else
text()
end
end
end,
function()
timer()
end
)
end
text()
Some one can help me?