function events()
evt, p1 = os.pullEvent()
if evt == "char" then --This is the event checker and if it is char it will check which char it was
if p1 == "r" then --This is if the user pressed the char 'r'
for i = 1,5 do
term.clear()
term.setCursorPos(20,9)
print("Rebooting.")
sleep(0)
term.clear()
term.setCursorPos(20,9)
print("Rebooting..")
sleep(0)
term.clear()
term.setCursorPos(20,9)
print("Rebooting...")
sleep(0)
end
os.reboot()
elseif p1 == "b" then
term.clear()
term.setCursorPos(1,1)
error() -- This breaks out of the program
elseif p1 == "s" then
for i = 1,5 do
term.clear()
term.setCursorPos(20,9)
print("Shutting Down.")
sleep(0)
term.clear()
term.setCursorPos(20,9)
print("Shutting Down..")
sleep(0)
term.clear()
term.setCursorPos(20,9)
print("Shutting Down...")
sleep(0)
end
os.shutdown()
end
elseif evt == "key" then
--[[
To get the key number of the one you choose you can just
open up the LUA prompt and type: 'while true do print(os.pullEvent()) end' without the ''
And then just press a key and the number for it will come up
]]--
if p1 == 28 then --Enter
color = 2 ^ math.random(0,15) --Randomly selects a background color
elseif p1 == 57 then --Space
tColor = 2 ^ math.random(0,15) --Randomly selects a text color
end
end
end --Ends the function
function drawMenu()
--[[
This function draws your options
]]--
term.setTextColor(tColor) --This sets the text color
print("[B]Break \n[S] Shutdown \n[R] Reboot \n[ENTER] Change background color \n[SPACE] Change text color") --\n = New line
end
function main()
color = colors.black --Default color
tColor = colors.white -- Default color
while true do
term.setBackgroundColor(color)
term.clear()
term.setCursorPos(1,1)
drawMenu()
events()
end
end
main() --You have to call the main function so your program actually does something