Posted 06 February 2016 - 09:59 AM
I'm trying to make a password program that only gives you a few tries and then you die, but I can't seem to get a counter to work!? Pleas Help! Here's my code
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.white)
function welcome()
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.white)
rednet.open(left)
local i = 3
term.setCursorPos(3,1)
print("Welome, please enter the password")
end
function correct()
term.setCursorPos(5,1)
term.setTextColor(colors.lime)
print("Correct! Opening Door!")
rs.setOutput("back", true)
sleep(2)
rs.setOutput("back", false)
welcome()
end
function incorrect()
term.setCursorPos(5,1)
term.setTextColor(color.red)
print(" Incorrect! Try Again!") then
local i= i-1
welcome()
if local i == 0 then
term.setCursorPos(7,1)
term.setTextSize(2)
print("YOU HAVE FAILED! YOU WILL NOW DIE!")
rednet.broadcast("die")
os.shutdown()
end
welcome()
input = read()
if input == "Illuminati" then
correct() else
incorrect()
What am I doing wrong?
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.white)
function welcome()
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.white)
rednet.open(left)
local i = 3
term.setCursorPos(3,1)
print("Welome, please enter the password")
end
function correct()
term.setCursorPos(5,1)
term.setTextColor(colors.lime)
print("Correct! Opening Door!")
rs.setOutput("back", true)
sleep(2)
rs.setOutput("back", false)
welcome()
end
function incorrect()
term.setCursorPos(5,1)
term.setTextColor(color.red)
print(" Incorrect! Try Again!") then
local i= i-1
welcome()
if local i == 0 then
term.setCursorPos(7,1)
term.setTextSize(2)
print("YOU HAVE FAILED! YOU WILL NOW DIE!")
rednet.broadcast("die")
os.shutdown()
end
welcome()
input = read()
if input == "Illuminati" then
correct() else
incorrect()
What am I doing wrong?
Edited on 06 February 2016 - 09:00 AM