Posted 17 December 2012 - 03:05 PM
I am creating an advanced password protected door to test my Lua skills, but I'm getting an error and I don't know what's causing it. Here is my code:
Here is a pastie link for those who want it: http://pastie.org/5541051
It works up until the point to where it asks for the password, if you enter it right you get this in the terminal:
No idea what's causing this, any help would be appreciated. :)/>
function clear()
term.setCursorPos(1,1)
term.clear()
end
clear()
local password -- Defines a string containing the password to be used in the door.
local openTime -- Defines an integer to be used to set how long the door will be open.
local availibleSides = {"top, ", "bottom, ", "left, ", "right, ", "front, ", "back", "\n"}
local redstoneOutputSide -- Defines a string to be used to set the output of a redstone signal.
local userInput -- Defines a string to be used with read().
print("Please define your desired password:") -- Prints the string defined by the quote marks.
password = read() --Setting the password string as whatever the user inputs.
clear() -- Calling the function I made.
print("Please define the amount of time the redstone pulse will be activated:") -- Already explained.
openTime = read() -- Already explained.
clear() -- Already explained.
print("On which side will the redstone be activated?") -- Already explained.
print("Availbe sides are:") -- Already explained.
for i = 1, 7 do
write(availibleSides[i])
end
print("Please define a side:")
redstoneOutputSide = read()
clear()
while true do
clear()
write("Please input password: ")
userInput = read("*")
if userInput == password then
clear()
print("Password is correct! Opening door...")
rs.setOutput(redstoneOutputSide, true)
sleep(openTime)
rs.setOutput(redstoneOutputSide, false)
else
print("Password is incorrect! Rebooting program...")
sleep(2)
end
end
Here is a pastie link for those who want it: http://pastie.org/5541051
It works up until the point to where it asks for the password, if you enter it right you get this in the terminal:
Password is correct! Opening door...
bios:133: Expected number
No idea what's causing this, any help would be appreciated. :)/>