Guest User

Untitled

a guest
Dec 3rd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. os.loadAPI("touchpoint")
  2.  
  3. --# intialize a new button set on the top monitor
  4. local t = touchpoint.new("top")
  5.  
  6. --# add two buttons
  7. t:add("left", nil, 2, 2, 14, 11, colors.red, colors.lime)
  8. t:add("right", nil, 16, 2, 28, 11, colors.red, colors.lime)
  9.  
  10. --# draw the buttons
  11. t:draw()
  12.  
  13. while true do
  14. --# handleEvents will convert monitor_touch events to button_click if it was on a button
  15. local event, p1 = t:handleEvents(os.pullEvent())
  16. if event == "button_click" then
  17. --# p1 will be "left" or "right", since those are the button labels
  18. --# toggle the button that was clicked.
  19. t:toggleButton(p1)
  20. --# and toggle the redstone output on that side.
  21. rs.setOutput(p1, not rs.getOutput(p1))
  22. end
  23. end
Add Comment
Please, Sign In to add comment