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

Help Adding A Redstone Output

Started by vette89, 28 August 2013 - 09:13 AM
vette89 #1
Posted 28 August 2013 - 11:13 AM
Hey guys new here and trying to figure out how to add something to this code (shown below) i want it to power a wire on left if password is incorrect (possibly if inccorect three times in a row) but just correct or incorrect would be fine as well. thanks for your time :)/>/>


password = ("amber")
side = ("right")

write ("admin password: ")
pword = read ()
if pword == (password) then
sleep(1)
print ("Password correct")
sleep(0.3)
print ("Oppening door...")
sleep(0.25)
print ("You have 5 seconds")
redstone.setOutput (side, true)
sleep(1)
print ("4")
sleep(1)
print ("3")
sleep(1)
print ("2")
sleep(1)
print ("1")
sleep(1)
print ("Closing door...")
sleep(0.25)
redstone.setOutput (side, false)
else
sleep(1)
print ("Password incorrect")
end
os.shutdown()
Edited by
Lyqyd #2
Posted 28 August 2013 - 01:43 PM
Split into new topic.

You've already got a redstone output on the right when the password is correct and a message output when the password is incorrect, so you clearly know how to use the redstone API and how to use the else statement. I suppose this isn't your code? Down where it has:


else
  sleep(1)
  print("Password incorrect")
end

Simply insert a couple redstone API calls much like you already have above:


else
  redstone.setOutput("left", true) --# turn on redstone output on left side
  sleep(1)
  print("Password incorrect")
  rs.setOutput("left", false) --# turn it off again. rs is short for redstone.
end
vette89 #3
Posted 28 August 2013 - 01:46 PM
I should have mentioned it wasnt mine, i got it off a tutorial. I will try that thanks! Update: Got it thank you! Now that i have a basic code i can learn off it lol.