Advertisement
Guest User

test

a guest
Dec 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  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, 8, 8, colors.red, colors.lime)
  12. t:add("back", nil, 10, 2, 16, 8, 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.         print(event)
  21.         print(p1)
  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.                 print(p1)
  26.                 --# and toggle the redstone output on that side.
  27.                 modem.transmit(12,12,p1)
  28.            
  29.         end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement