Advertisement
chezpaul

Redstone Cables 2

Nov 28th, 2015
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. --# load the Touchpoint API
  2. loadup = function()
  3. shell.run("pastebin", "get", "h2qXpRLG", "touchpoint")
  4. os.loadAPI("touchpoint")
  5. print("Touchpoint API Loaded")
  6. sleep(1)
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. end
  10.  
  11. loadup()
  12.  
  13. --# Redstone Cable Bug
  14. function colours.subtract(cols, ...)
  15. for i = 1, #arg do
  16. if bit.band(cols, arg[i]) == arg[i] then
  17. cols = cols - arg[i]
  18. end
  19. end
  20. return cols
  21. end
  22. colors.subtract = colours.subtract
  23.  
  24. --# intialize a new button set on the top monitor
  25. local t = touchpoint.new("top")
  26.  
  27.  
  28. --# rs.setBundledOutput ORANGE.
  29. function OrangeAction()
  30. t:toggleButton("Pump")
  31. rs.setBundledOutput("back", (colors.test(rs.getBundledOutput("back"), colors.orange) and colors.subtract(rs.getBundledOutput("back"), colors.orange) or colors.combine(rs.getBundledOutput("back"), colors.orange)))
  32. end
  33.  
  34. --# rs.setBundledOutput GREY.
  35. function GrayAction()
  36. t:toggleButton("Refinery")
  37. rs.setBundledOutput("back", (colors.test(rs.getBundledOutput("back"), colors.gray) and colors.subtract(rs.getBundledOutput("back"), colors.gray) or colors.combine(rs.getBundledOutput("back"), colors.gray)))
  38. end
  39.  
  40. --# rs.setBundledOutput YELLOW.
  41. function YellowAction()
  42. t:toggleButton("Central")
  43. rs.setBundledOutput("back", (colors.test(rs.getBundledOutput("back"), colors.yellow) and colors.subtract(rs.getBundledOutput("back"), colors.yellow) or colors.combine(rs.getBundledOutput("back"), colors.yellow)))
  44. end
  45.  
  46. --# rs.setBundledOutput BLUE.
  47. function BlueAction()
  48. t:toggleButton("Fluid")
  49. rs.setBundledOutput("back", (colors.test(rs.getBundledOutput("back"), colors.blue) and colors.subtract(rs.getBundledOutput("back"), colors.blue) or colors.combine(rs.getBundledOutput("back"), colors.blue)))
  50. end
  51.  
  52.  
  53. --# Main Function.
  54. buttonLoads = function()
  55. t:add("REFINERY", nil, 4, 1, 16, 3, colors.black, colors.black)
  56. t:add("REACTOR", nil, 18, 1, 30, 3, colors.black, colors.black)
  57. t:add("Pump", OrangeAction, 4, 4, 16, 7, colors.red, colors.lime)
  58. t:add("Refinery", GrayAction, 4, 9, 16, 12, colors.red, colors.lime)
  59. t:add("Central", YellowAction, 18, 4, 30, 7, colors.red, colors.lime)
  60. t:add("Fluid", BlueAction, 18, 9, 30, 12, colors.red, colors.lime)
  61.  
  62. t:draw()
  63. end
  64.  
  65. buttonLoads()
  66. t:run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement