Guest User

Untitled

a guest
Jul 20th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. --# load the touchpoint API
  2. os.loadAPI("touchpoint")
  3.  
  4. --# intialize a new button set on the top monitor
  5. local t = touchpoint.new("top")
  6.  
  7. local function toggleBundledColor(side, color)
  8.   rs.setBundledOutput(side, (colors.test(rs.getBundledOutput(side), color) and colors.subtract(rs.getBundledOutput(side), color) or colors.combine(rs.getBundledOutput(side), color)))
  9. end
  10.  
  11. local function test()
  12.   toggleBundledColor("back", colors.white)
  13. end
  14.  
  15. t:add("Test", test, 2, 2, 9, 4, colors.red, colors.cyan)
  16. --# draw the buttons
  17. t:draw()
  18.  
  19. while true do
  20.         --# handleEvents will convert monitor_touch events to button_click if it was on a button
  21.         local event, p1 = t:handleEvents(os.pullEvent())
  22.         if event == "button_click" then
  23.                 --# p1 will be "left" or "right", since those are the button labels
  24.                 --# toggle the button that was clicked.
  25.                 t:toggleButton(p1)
  26.                 t.buttonList[p1].func()
  27.  
  28.                 --# and toggle the redstone output on that side.
  29.                 --# rs.setOutput(p1, not rs.getOutput(p1))
  30.         end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment