Jump to content




Door Lock.


  • You cannot reply to this topic
3 replies to this topic

#1 Platinum_Apple

  • New Members
  • 1 posts

Posted 15 June 2012 - 10:42 PM

Every time i run this code:

local side = "left"
local password = "bacon"
local opentime = 5
term.clear()
term.setCursorPos(1,1)
write("Password: ")
local input = read("*")
if input == (password) then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
rs.setOutput(side,true)
sleep(5)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Password incorrect!")
sleep(2)
os.reboot()
end

I get the "bios:206: [string "startup"]:10: '=' expected"
error.
Help?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 16 June 2012 - 12:07 AM

Well, for one thing, take password out of the parentheses. They're unnecessary there. You should probably also run that in an infinite loop, so that the computer doesn't have to reboot unnecessarily.

#3 Bossman201

  • New Members
  • 92 posts

Posted 16 June 2012 - 01:18 AM

Code works fine when I run it. Couple things I've noticed, though.

1. Use some kind of formatting.
2.
sleep(5) -- should be sleep(openTime)
3.
rs.setOutput(side, true)
rs.setOutput(side, false) --no sense in creating and keeping track of a variable you do not need, rs.setOutput("left", true) will do just fine.


#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 16 June 2012 - 08:46 AM

View PostBossman201, on 16 June 2012 - 01:18 AM, said:

2.
sleep(5) -- should be sleep(openTime)
3.
rs.setOutput(side, true)
rs.setOutput(side, false) --no sense in creating and keeping track of a variable you do not need, rs.setOutput("left", true) will do just fine.

Um, pick one. He either should use variables declared at the top in both places, or neither. They're the same use case, so why are you suggesting using the variable in one place and taking it out in another?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users