Jump to content




Why isnt thism working?


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

#1 X3ME

  • Members
  • 82 posts
  • LocationBeing the stereotypical kid in forums.

Posted 16 November 2014 - 05:51 PM

Just made this code

local side = "left"
local password = "bacon"
local opentime = 5
while true do
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(opentime)
  rs.setOutput(side,false)

elseif redstone.getInput ("left") then
  print("Terminal Blocked")
  sleep (3)
 
  else
  print ("Password Incorrect")
  sleep(2)
end
end

So, the porpuse is to be a normal door lock but it doesn't work when it has a redstone signal from the left.

But it dosen't work! Why?

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 16 November 2014 - 06:06 PM

elseif redstone.getInput ("left") then
  print("Terminal Blocked")
  sleep (3)
 

Remove that entire block and it should work normally, why do you have it in there?

#3 wieselkatze

  • Members
  • 221 posts
  • LocationGermany

Posted 16 November 2014 - 06:16 PM

I'm pretty sure he meant that it still opens the door, even when the computer has an input from the left side.

The reason for that is, that it only checks for the signal when the password is incorrect.
Just swap the password checking and the redstone part, so it looks like this:
local side = "left"
local password = "bacon"
local opentime = 5
while true do
  term.clear()
  term.setCursorPos(1,1)
  write("Password: ")
  local input = read("*")
  if redstone.getInput ("left") then
    print("Terminal Blocked")
    sleep (3)
  elseif input == password then
    term.clear()
    term.setCursorPos(1,1)
    print("Password correct!")
    rs.setOutput(side,true)
    sleep(opentime)
    rs.setOutput(side,false)
  else
    print ("Password Incorrect")
    sleep(2)
  end
end

Edited by wieselkatze, 16 November 2014 - 06:20 PM.


#4 X3ME

  • Members
  • 82 posts
  • LocationBeing the stereotypical kid in forums.

Posted 16 November 2014 - 06:35 PM

I want it to be normal, but i want it to block when it has a rs signal from left

#5 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 16 November 2014 - 06:40 PM

View PostX3ME, on 16 November 2014 - 06:35 PM, said:

I want it to be normal, but i want it to block when it has a rs signal from left

In that case, wieselkatze has the fix.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users