Posted 30 July 2014 - 03:47 PM
I have been writing a lock for my computers from scratch in lua for computercraft but have encountered an error. The error is the startup:16: attempt to call string as the title says here is the code I have come up with for the lock.
Any help will be appreciated, thanks.
username = "qwerty"
username2 = "qwerty"
password = "123"
password2 = "123"
openTime = 5
rebootTime = 2
waitTime = 3
while true do
os.pullEvent =os.pullEventRaw
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint("Frag Lock V1.2")
username()
function username()
write("Username: ")
usernameinput = read()
if usernameinput == username or username2 then
password()
else
textutils.slowPrint("Username Incorrect please try again!")
usernameincorrect()
end
end
function password()
write("Password: ")
passwordinput = read()
if passwordinput == password or password2 then
correct()
else
passwordincorrect()
end
end
function correct()
redstone.setOutput("left", true)
sleep(openTime)
redstone.setOutput("left", false)
textutils.slowPrint("Rebooting...")
sleep(rebootTime)
os.reboot()
end
function usernameincorrect()
textutils.slowPrint("Username Incorrect! Try again later.")
sleep(waitTime)
textutils.slowPrint("Rebooting...")
sleep(rebootTime)
os.reboot()
end
function passwordincorrect()
textutils.slowPrint("Password Incorrect! Try again later.")
sleep(waitTime)
textutils.slowPrint("Rebooting...")
sleep(rebootTime)
os.reboot()
end
end
Any help will be appreciated, thanks.