Advertisement
LivioBrunner

bla

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