Quipex

Disk/mem/redworks/programs/circuits/AND

Apr 23rd, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. --2
  2. --1
  3. --0
  4. input = {}
  5. output = {}
  6. extra = {}
  7. input[1] = "left"
  8. input[2] = "right"
  9. output[1] = "back"
  10.  
  11. -- AND Gate
  12. -- Created by: Streetstar5 aka FuzzyPurp
  13.  
  14. term.clear()
  15. term.setCursorPos(1,2)
  16. print("AND Gate is now running.")
  17. print("Input(s): " .. input[1] .. ", " .. input[2] .. ".")
  18. print("Output(s): " .. output[1] .. ".")
  19. print("\nPress Q to terminate.")
  20.  
  21. while true do
  22.  
  23. --wait on an event
  24. event, param = os.pullEvent()
  25.  
  26. -- Key event. Q key will exit to shell.
  27. if event == "char" and string.lower(param) == "q" then
  28. print("Device stopped")
  29. break
  30. end
  31. --Now on to the actual Logic gate.
  32.  
  33. if rs.getInput(input[1]) == rs.getInput(input[2]) then
  34. rs.setOutput(output[1], true)
  35. else
  36. rs.setOutput(output[1], false)
  37. end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment