This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ModeratlySexy's profile picture

need help :(

Started by ModeratlySexy, 22 January 2016 - 09:49 PM
ModeratlySexy #1
Posted 22 January 2016 - 10:49 PM
hey.. so i have a question. i want to make a door that when you type one password it outputs redstone to one side and when you type a different one it outputs to a different side. any suggestions
Lyqyd #2
Posted 23 January 2016 - 01:27 AM
Moved to Ask a Pro.
HPWebcamAble #3
Posted 23 January 2016 - 01:46 AM
Something like this should work:


while true do --# Infinite loop

  local input = read() --# Let the user type a password

  if input == "myPassword" then --# User entered 'myPassword'

    rs.setOutput("back",true)
    print("Correct!")
    sleep(2)
    rs.setOutput("back",false)

  else --# User entered something else

    rs.setOutput("bottom",true)
    print("Wrong!")
    sleep(2)
    rs.setOutput("bottom",false)

  end

end

Note that it isn't very secure, I tried to keep it simple for now
cyanisaac #4
Posted 23 January 2016 - 06:09 PM
Something like this should work:


while true do --# Infinite loop

  local input = read() --# Let the user type a password

  if input == "myPassword" then --# User entered 'myPassword'

	rs.setOutput("back",true)
	print("Correct!")
	sleep(2)
	rs.setOutput("back",false)

  else --# User entered something else

	rs.setOutput("bottom",true)
	print("Wrong!")
	sleep(2)
	rs.setOutput("bottom",false)

  end

end

Note that it isn't very secure, I tried to keep it simple for now

One line of code makes this secure. Add to the top:

os.pullEvent = os.pullEventRaw
Edited on 23 January 2016 - 05:09 PM