Sazra

tpTest

May 20th, 2022 (edited)
714
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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("back")
  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.                 --# and toggle the redstone output on that side.
  22.                 rs.setOutput(p1, not rs.getOutput(p1))
  23.         end
  24. end
RAW Paste Data Copied