Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 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. --# add two buttons
  8. t:add("left", nil, 2, 2, 14, 11, colors.red, colors.lime)
  9. t:add("right", nil, 16, 2, 28, 11, colors.red, colors.lime)
  10.  
  11. --# draw the buttons
  12. t:draw()
  13.  
  14. while true do
  15. --# handleEvents will convert monitor_touch events to button_click if it was on a button
  16. local event, p1 = t:handleEvents(os.pullEvent())
  17. if event == "button_click" then
  18. --# p1 will be "left" or "right", since those are the button labels
  19. --# toggle the button that was clicked.
  20. t:toggleButton(p1)
  21. print(p1)
  22. --# and toggle the redstone output on that side.
  23. rs.setOutput(p1, not rs.getOutput(p1))
  24. end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement