Posted 09 October 2012 - 01:23 AM
I wan't to make my menu system stop once an option is executed. So far I can make it run a different program but the menu still lingers, fully functional. I wan't this to go away and I don't know how. Here's my code.
function menu(id, text)
if sid == id then
write"> "
else
write"* "
end
print(text)
end
TerminalMode = 0
function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
if TerminalMode == 0 then
end
end
return event, p1, p2, p3, p4, p5
end
term.clear()
term.setCursorPos(1, 2)
print(" #################################################")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" # #")
print(" #################################################")
term.setCursorPos(15, 1)
print("State Bank of the Craft")
term.setCursorPos(45, 1)
print("ATM #1")
sid = 0
while true do
term.setCursorPos(15,8)
menu(0, "Withdraw")
term.setCursorPos(15,9)
menu(1, "Deposit")
term.setCursorPos(15,10)
menu(2, "Check Balance")
event, key = os.pullEvent("key")
if key == 200 then
if sid == 0 then
sid = sid + 2
elseif sid == 1 then
sid = sid - 1
elseif sid == 2 then
sid = sid - 1
end
end
if key == 208 then
if sid == 0 then
sid = sid + 1
elseif sid == 1 then
sid = sid + 1
elseif sid == 2 then
sid = sid - 2
end
end
if key == 28 then
if sid == 0 then
shell.run("/withdraw") -- I wan't the menu to stop when this program runs.
elseif sid == 1 then
shell.run("/deposit") -- And this one.
elseif sid == 2 then
shell.run("/checkbal") -- And this one.
end
end
if key == 42 then
event, key2 = os.pullEvent("key")
term.setCursorPos(45, 17)
print("CTRLP")
if key2 == 46 then
shell.run("/controlpanel")
end
end
end