If you're trying to get the program to exit without shutting down the computer, you could try the previous poster's code ^^ or this little snippet:
shell.run("clear")
function printMainMenu()
print (" Panic Room Door control 0.2v")
print (" ----------------------------")
print (" [1] Open Door ")
print (" [2] Close Door ")
print (" [3] Exit ")
print (" [4] Shutdown Computer ")
end
while true do
shell.run("clear") -- Moving this line up here will simply clear the screen every time until the loop is broken
printMainMenu()
input = read.io()
yes = "1"
no = "2"
yo = "3"
la = "4"
if input == yes then
redstone.setOutput ("back", false)
shell.run("startup")
elseif input == no then
redstone.setOutput ("back", true)
shell.run("startup")
end
elseif input == yo then break
-- the break keyword will 'break' or end/exit the current loop. Our while true loop will stop,
-- the program will end, and the user will be prompted with the familiar CraftOS screen.
elseif input == la then
sleep(1)
os.shutdown()
end
Similarly, if you wanted to get the computer to just reboot so the user would be prompted with the boot up screen ("CraftOS 1.3 >_") then you could try this:
shell.run("clear")
function printMainMenu()
print (" Panic Room Door control 0.2v")
print (" ----------------------------")
print (" [1] Open Door ")
print (" [2] Close Door ")
print (" [3] Exit ")
print (" [4] Shutdown Computer ")
end
while true do
shell.run("clear") -- Moving this line up here will simply clear the screen every time until the loop is broken
printMainMenu()
input = read.io()
yes = "1"
no = "2"
yo = "3"
la = "4"
if input == yes then
redstone.setOutput ("back", false)
shell.run("startup")
elseif input == no then
redstone.setOutput ("back", true)
shell.run("startup")
end
elseif input == yo then os.reboot()
elseif input == la then
sleep(1)
os.shutdown()
end