Advertisement
ValveCantCount

ValveCantCount Reactor

Nov 16th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. os.loadAPI("touchpoint")
  2. os.loadAPI("GraphicsAPI")
  3.  
  4. local t = touchpoint.new("right")
  5. GraphicsAPI.drawLine( {1,5}, GraphicsAPI.packXY(8, 3), colors.lime ) -- Draw a green line from (1,5) to (8,2).
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement