Posted 19 January 2013 - 10:34 AM
Okay, so I have made a menu program to open a door, it is not yet 100% complete but it is in it's BETA form, However I have just discovered that when I get to my menus my secondary options do not work. EX: when I highlight my secondary commands "Admin Control" and/or "Back", neither does what the script says they are supposed to do but instead ignore what I have written, errr…typed…,and restart the loop therefore highlighting the command above them which undoubtedly works. I have looked and played and changed a lot but cannot identify the source of the issue and make my secondary options work. If you believe you could fix it then here's a copy of it below.
--Variables.st
T0 = "Main Menu"
T1 = " Open"
T2 = " Admin Control"
T3 = " Back"
--Variables.hl
S1 = "*Open*"
S2 = "*Admin Control*"
S3 = "*Back*"
--Console_Terms
function clear()
term.clear()
end
function Mid()
term.setCursorPos(22.5,1)
end
--Resident_Menu.Res1
function Res1()
term.clear()
term.setCursorPos(22.5,1)
print(T0)
print(S1)
print(T2)
while true do
event, msi = os.pullEvent("key")
if msi == 28 then
Open=true
break
elseif msi == 208 or 200 then
Res2()
break
end
end
end
--Resident_Menu.Res2
function Res2()
term.clear()
term.setCursorPos(22.5,1)
print(T0)
print(T1)
print(S2)
while true do
event, Admin = os.pullEvent("key")
if Admin == 208 or 200 then
term.clear()
term.setCursorPos(1,1)
Res1()
break
elseif Admin == 28 then
term.clear()
term.setCursorPos(1,1)
admin=true
break
end
end
end
--Admin_function
while admin == true do
pass = "25439w4hjd134673"
write ("Password: ")
input = read("*")
if input == pass then
sleep(1.5)
print("Password Valid")
term.clear()
term.setCursorPos(1,1)
break
elseif input ~= pass then
sleep(1.5)
print ("Password Invalid.")
Res1()
break
end
end
--Visitor_Menu.Vis
function vis()
clear()
Mid()
print(T0)
print(S1)
print(T3)
while true do
event, v = os.pullEvent("key")
if v == 200 or 208 then
vis1()
break
elseif v == 28 then
Open=true
break
end
end
end
--Vistor_Menu.vis1
function vis1()
clear()
Mid()
print(T0)
print(T1)
print(S3)
while true do
event, s = os.pullEvent("key")
if s == 200 then
vis()
break
elseif s == 208 then
vis()
break
elseif s == 28 then
os.reboot()
break
end
end
end
--Welcome_Msg
w=true
while w == true do
term.clear()
term.setCursorPos(17.5,1)
print[[Residents press R
or
Visitors press V]]
while true do
local event, c = os.pullEvent("char")
c = string.lower(c)
if c == "r" then
w=false
Res1()
break
elseif c == "v" then
w=false
vis()
break
end
end
end
--Open_Command
while Open == true do
rs.setOutput("back", false)
s=15
while true do
term.clear()
term.setCursorPos(22.5,1)
print ("Opening Door")
term.setCursorPos(22.5,2)
print("Closing in.."..s)
sleep(1)
s = s-1
if s == 0 then
term.clear()
term.setCursorPos(17.5,1)
print "Times up! Closing Door!"
rs.setOutput("back", true)
sleep(2)
Open=false
os.reboot()
break
end
end
break
end