Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. modem = peripheral.wrap("back")
  2. modem.open(12)
  3.  
  4. --# load the touchpoint API
  5. os.loadAPI("touchpoint")
  6.  
  7. --# intialize a new button set on the top monitor
  8. local t = touchpoint.new("top")
  9.  
  10. --# add two buttons
  11. t:add("for", nil, 2, 2, 6, 6, colors.red, colors.lime)
  12. t:add("back", nil, 8, 2, 12, 6, colors.red, colors.lime)
  13.  
  14. --# draw the buttons
  15. t:draw()
  16.  
  17. while true do
  18.         --#HandleEvents will convert monitor_touch events to button_click if it was on a button
  19.         local event, p1 = t:handleEvents(os.pullEvent())
  20.         if event == "button_click" then
  21.                 --# p1 will be "left" or "right", since those are the button labels
  22.                 --# toggle the button that was clicked.
  23.                 t:flash(p1)
  24.                 --# and toggle the redstone output on that side.
  25.                 modem.transmit(12,12,p1)
  26.            
  27.         end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement