Advertisement
chezpaul

lightswitch

Nov 27th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 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("front")
  26.  
  27. --# rs.setBundledOutput WHITE.
  28. function WhiteAction()
  29. t:toggleButton("Power")
  30. rs.setBundledOutput("back", (colors.test(rs.getBundledOutput("back"), colors.white) and colors.subtract(rs.getBundledOutput("back"), colors.white) or colors.combine(rs.getBundledOutput("back"), colors.white)))
  31. end
  32.  
  33. --# Main Function.
  34. buttonLoads = function()
  35. t:add("Lights", nil, 1, 1, 7, 1, colors.black, colors.black)
  36. t:add("Power", WhiteAction, 2, 2, 6, 4, colors.red, colors.lime)
  37.  
  38.  
  39. t:draw()
  40. end
  41.  
  42. buttonLoads()
  43. t:run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement