Posted 17 August 2014 - 10:23 PM
The Error I am Getting is bios:366: [string "startup"]:12: 'end'expected (to close 'if' at line 10)
I have looked at the code for many hours and can't figure it out please help! And yes I know that the error means that there's not enough block ends but I've looked and looked and I think I should be getting a eof not an end error. If you see any other ways to fix any bugs or improve the code please tell me I've been using cumputer craft to learn about lua so I would love it if you could help with that to thanks :)/>.
I have looked at the code for many hours and can't figure it out please help! And yes I know that the error means that there's not enough block ends but I've looked and looked and I think I should be getting a eof not an end error. If you see any other ways to fix any bugs or improve the code please tell me I've been using cumputer craft to learn about lua so I would love it if you could help with that to thanks :)/>.
--Variables
pass = "12345"
maxFails = "3"
numFails = "0"
--Functions
--check Passcode
function checkPasscode()
if io.read == pass then
return true
numFails = 0
else
return false
numFails = numFails + 1
end
end
end
--Check Fails
function checkFails()
if checkPasscode() == false then
if numFails == maxFails then
return true
else if numFails > maxFails then
return true
elseif checkPasscode() == true then
return false
else
return false
end
end
end
--Fails Seter
function setFails()
if checkFails() == true then
if checkPasscode() false then
numFails = numFails + 1
return true
elseif check Fails() == false then
numFails = 0
return true
else
return false
--clear
function clear()
term.clear
term.setCursorPos(1,1)
end
--Looped Code
while true do
clear()
print(" ")
print(" Enter Your Passcode. ")
print(" o-----o ")
write(" | | ")
print(" o-----o ")
term.setCursorPos(28,4)
if checkPasscode() == true then
setFails()
term.clear
term.setCursorPos(1,2)
io.read("*")
print(" o-----------------o")
print(" |Correct Passcode!|")
print(" | |")
print(" | Access Granted! |")
print(" o-----------------o")
sleep(3)
term.clear
io.read()
print(" o----------------------o")
print(" | Security Mode |")
print(" o----------------------o")
print(" |Press 1 to Activate |")
print(" |Prees 2 to DeActivate |")
print(" o----------------------o")
if io.read == 1 then
term.clear
print(" Activated")
rs.setOutput("back",true)
sleep(15)
else if io.read == 2 then
term.clear
print(" DeActivated")
rs.setOutput("back",false)
sleep(4)
else
term.clear
print(" Unknown Input")
sleep(3)
term.clear
else if checkPasscode == false then
setFails()
print(" Wrong passcode")
sleep(3)
if checkFails == true then
setFails()
print(" To Many Fails Kicked from system for 30 seconds.")
sleep(30.2)
term.clear
else if checkFails == false then
print(" Try Agin")
sleep(5)
term.clear
end
end
end
Edited on 18 August 2014 - 01:10 AM