Posted 21 June 2014 - 06:29 AM
I made an advanced password program with tries and auto-lock. But I have a question : Each time it I "voluntary" make a mistake, it has a bug while counting and I can't set it to 0 every time :(/>. It says word by word : password:21: attempt to call arithmetic __add on nil and number
- local password = "Password" – Password local side = "left" – Side to send the redstone signal local time = 5 – Activation time for the signal local totalTry = 5 – Total tries before self-locking while true do term.clear() local try = try print("Password : ") local input = read("*") if input == password then term.clear() print("Password correct !") rs.setOutput(side, true) local try = 0 os.sleep(time) rs.setOutput(side, false) else term.clear() print("Wrong password !") local try = try+1 if try == totalTry then print("Computer locked for 60 seconds !") os.sleep(60) else term.write("Essaie restante : ") term.write(totalTry-try) – The error says to be here ! term.write(" !") end os.sleep(2) end end
Edited on 21 June 2014 - 04:42 PM