PeeWeeSweden

KSubNet control program

Nov 10th, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. -- KSubNet control program --
  2.  
  3. -- VARS --
  4.  
  5. -- FUNCTIONS --
  6. function displayColors()
  7. if colors.test(redstone.getBundledInput("back"), colors.red) then
  8. setDestination("east")
  9. elseif colors.test(redstone.getBundledInput("back"), colors.blue) then
  10. setDestination("west")
  11. elseif colors.test(redstone.getBundledInput("back"), colors.yellow) then
  12. setDestination("south")
  13. elseif colors.test(redstone.getBundledInput("back"), colors.green) then
  14. setDestination("north")
  15. end
  16. end
  17.  
  18. function setDestination(dest)
  19. print(dest)
  20. if dest == "east" then
  21. rs.setBundledOutput("bottom",colors.combine(colors.green,colors.orange))
  22. sleep(1)
  23. rs.setBundledOutput("bottom",colors.green)
  24. elseif dest == "south" then
  25. rs.setBundledOutput("bottom",colors.combine(colors.red,colors.orange))
  26. sleep(1)
  27. rs.setBundledOutput("bottom",colors.red)
  28. elseif dest == "north" then
  29. rs.setBundledOutput("bottom",colors.combine(colors.blue,colors.orange))
  30. sleep(1)
  31. rs.setBundledOutput("bottom",colors.blue)
  32. else
  33. rs.setBundledOutput("bottom",colors.orange)
  34. sleep(1)
  35. rs.setBundledOutput("bottom",0)
  36. end
  37. end
  38.  
  39. -- MAIN --
  40. monitor = peripheral.wrap("top")
  41. monitor.setTextScale(0.5)
  42. term.redirect(monitor)
  43. term.clear()
  44. term.setCursorPos(1,1)
  45.  
  46. while true do
  47. local event = os.pullEvent("redstone")
  48. displayColors()
  49. end
  50.  
  51. term.restore()
  52. -- END -
Advertisement
Add Comment
Please, Sign In to add comment