Posted 05 May 2012 - 08:13 PM
I've been trying to make a simple interface for my base.
I get a bug where I start up the program, and it prints the "Not a valid command!" dialog, then shows the menu. However, upon a keypress, it exits the program.
Here's my code:
I get a bug where I start up the program, and it prints the "Not a valid command!" dialog, then shows the menu. However, upon a keypress, it exits the program.
Here's my code:
--Made by NegativePositive
--The +OS
sleep(1)
function home()
term.clear()
term.setCursorPos(1,1)
rednet.open("right")
rednet.open("top")
rednet.open("left")
rednet.open("back")
print("Welcome to the Mainframe!")
print("Choose one of the options:")
term.setCursorPos(1,4)
print("A: Turn the day/night sensor on or off.")
print("B: Harvest melons.")
print("C: Exit to CraftOS.")
event, param1, param2 = os.pullEvent()
end
term.clear()
if event == char and param1 == a then
rednet.send(1,"toggle")
print("Day/night sensor toggled!")
sleep(1)
home()
elseif event == char and param1 == b then
rednet.send(2, "harvest")
print("Melons harvested!")
sleep(1)
home()
elseif event == char and param1 == c then
term.clear()
shell.exit()
else
print("Not a valid command!")
sleep(1)
home()
end