Posted 27 June 2014 - 04:45 AM
For some reason, even if I press the "5"-key, the computer does not shut down like it should.
What am I doing wrong here?
What am I doing wrong here?
local cafos = {
dialogs = {
mainuserwindow = {
"CafOS",
"2014 (c) Caffeine Spider Ltd",
"Logged in as blablalb",
"",
"1. Transmit wireless signal",
"2. Shut down mainframe",
"3. Information",
"4. Log out",
"5. Shut down",
"6. Boot from Disk",
"7. More"
},
}}
function createDialog(opts, getInput, password, textInput)
clear()
for k,v in pairs(opts) do
write(v.."\n")
end
if getInput then
if textInput then
if password then
local inp = read("*")
return inp
else
local inp = read()
return inp
end
else
local event, key = os.pullEvent("char")
return keys.getName(key)
end
end
return true
end
function clear(noCursor)
term.clear()
if noCursor == nil then
term.setCursorPos(1,1)
end
end
function update()
clear()
local menuSelection = createDialog(cafos.dialogs.mainuserwindow, true, false, false)
if menuSelection == "one" then
--asdasddsds
elseif menuSelection == "two" then
--asdasddsds
elseif menuSelection == "three" then
--asdasddsds
elseif menuSelection == "four" then
--asdasddsds
elseif menuSelection == "five" then
print("")
print("Shutting down..")
sleep(1)
os.shutdown()
elseif menuSelection == "six" thenend
return true
end
while true do
local runtime = update()
if runtime == false then
break
end
end
Edited on 27 June 2014 - 02:48 AM