why doesn't my computercraft program works?

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

martin0leung

New Member
Jul 29, 2019
35
0
0
function clear()
term.clear()
term.setCursorPos(1,1)
end

clear()
print("please type in the password")

function lock()
os.pullEvent = os.pullEventRaw
end

local pass = 322221

term.setCursorPos(1,5)
write("password:")
input = read("*")
if pass == input then
print("Password correct!")
redstone.setOutput("top",true)
sleep(5)
redstone.setOutput("top",false)
shell.run("reboot")
else
print("password incorrect!")
shell.run("reboot")
end

and every time I run it, even if I type the right password, it just say password incorrect!
 
I'm no master in coding by any stretch of the imagination, but it seems to me like you've forgotten to specify your local pass to a function. (???)
 
Don't know how LUA handles type conversion, but you could try converting your password to a string.

Code:
local pass = "322221"

Edit, from LUA wiki:

A notable exception: comparison operators (== ~= < > <= >=) do not coerce their arguments.