I have this bit of code but when it gets to the choice part it ignores the rest of the code and doesn't let me input a choice
y = colors.combine( colors.yellow )
r = colors.combine( colors.red )
rr = colors.subtract( colors.red )
yy = colors.subtract( colors.yellow )
term.clear()
--local pullEvent = os.pullEvent
--os.pullEvent = os.pullEventRaw
sfile = io.open("/startup", "w")
sfile:write('shell.run("door")')
sfile:close()
term.setCursorPos(1,1)
print(" -----------Giuseppe's Burgeria-----------")
print("")
print("")
print("")
print(" Please Enter Your Password")
print(" Password:")
term.setCursorPos(20,6)
local input = read("*")
if input == "potato" then
term.clear()
term.setCursorPos(1,1)
sleep(1)
print(" -----------Giuseppe's Burgeria-----------")
print("")
print("")
print("")
print(" 1.Open Main Doors")
print(" 2.Close Main Doors")
print("")
print(" 3.Open Farm Doors")
print(" 4.Close Farm Doors")
print("")
print(" 5.Logout")
print("")
term.setCursorPos(15,13)
if input == "1" then
rs.setBundledOutput( "down", y )
print("Open")
elseif input == "2" then
rs.setBundledOutput( "down", yy )
print("Closed")
elseif input == "3" then
rs.setBundledOutput( "down", r )
print("Open")
elseif input == "4" then
rs.setBundledOutput( "down", rr )
print("Closed")
elseif input == "5" then
os.reboot()
elseif input =="admin1" then
fs.delete("startup")
print(" auto start disabled")
sleep(1)
else
end
else
print(" Wrong Password")
sleep(1)
os.reboot()
end
I'm not sure why this isn't working
Started by crazyjoe567, Apr 11 2013 10:46 AM
6 replies to this topic
#1
Posted 11 April 2013 - 10:46 AM
#2
Posted 11 April 2013 - 11:01 AM
You are only calling io.read() once, so input is equal to "potato" and you're asking if it's equal to some numbers.
Here's what you have:
Here's what it should be:
That should work I think!
Also, I would suggest putting that amount of code into a code brick and also a spoiler. Just makes it nicer to read!
Here's what you have:
term.setCursorPos(15,13) if input == "1" then --etc.
Here's what it should be:
term.setCursorPos(15,13) input = io.read() if input == "1" then --etc.
That should work I think!
Also, I would suggest putting that amount of code into a code brick and also a spoiler. Just makes it nicer to read!
#3
Posted 11 April 2013 - 11:05 AM
Ok thanks I will try this!
#4
Posted 11 April 2013 - 11:08 AM
Also I put down instead of bottom again :/
#5
Posted 11 April 2013 - 11:11 AM
Also how do you loop the choice part so it only stops when I type 5
#6
Posted 11 April 2013 - 11:26 AM
Just wrap it in a while loop.
while true do
if input == "1" then
rs.setBundledOutput( "down", y )
print("Open")
elseif input == "2" then
rs.setBundledOutput( "down", yy )
print("Closed")
elseif input == "3" then
rs.setBundledOutput( "down", r )
print("Open")
elseif input == "4" then
rs.setBundledOutput( "down", rr )
print("Closed")
elseif input == "5" then
break
elseif input =="admin1" then
fs.delete("startup")
print(" auto start disabled")
sleep(1)
end
end
#7
Posted 11 April 2013 - 11:33 AM
thanks
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











