Posted 21 July 2012 - 10:29 AM
Basically im making a password door with a trojan(a piece of program) in that allows me to open the door as well using rednet.
i want a way to get the input from the terminal without it stopping a loop, for example i want it to wait 1 second, if the password hasnt been typed in then it will bypass that line and move on, this is the code so far:
time = 2
side = "left"
password = "password"
rednet.open("right")
id = 0
term.clear()
term.setCursorPos(1,1)
term.write("Password>")
while true do
id, message = rednet.receive(1)
if id == 1020 then
if message == "UPDATE" then
term.clear()
term.setCursorPos(1,1)
term.write("System has an update available")
break
end
if message == "TROJANON" then
term.clear()
term.setCursorPos(1,1)
redstone.setOutput(side, true)
end
if message == "TROJANOFF" then
term.clear()
term.setCursorPos(1,1)
redstone.setOutput(side, false)
end
end
input = io.read()
if input == password then
term.clear()
term.setCursorPos(1,1)
term.write("Password>")
redstone.setOutput(side, true)
sleep(time)
redstone.setOutput(side, false)
end
end
i want a way to get the input from the terminal without it stopping a loop, for example i want it to wait 1 second, if the password hasnt been typed in then it will bypass that line and move on, this is the code so far:
time = 2
side = "left"
password = "password"
rednet.open("right")
id = 0
term.clear()
term.setCursorPos(1,1)
term.write("Password>")
while true do
id, message = rednet.receive(1)
if id == 1020 then
if message == "UPDATE" then
term.clear()
term.setCursorPos(1,1)
term.write("System has an update available")
break
end
if message == "TROJANON" then
term.clear()
term.setCursorPos(1,1)
redstone.setOutput(side, true)
end
if message == "TROJANOFF" then
term.clear()
term.setCursorPos(1,1)
redstone.setOutput(side, false)
end
end
input = io.read()
if input == password then
term.clear()
term.setCursorPos(1,1)
term.write("Password>")
redstone.setOutput(side, true)
sleep(time)
redstone.setOutput(side, false)
end
end