Advertisement
chezpaul

Redstone

Oct 12th, 2015
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 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.  
  7. --# add a title
  8. t:add("Redstone Control Grid", nil, 2, 2, 20, 4, colors.black, colors.black)
  9.  
  10. --# add two buttons
  11. t:add("Oil Pump", nil, 2, 6, 10, 12, colors.red, colors.lime)
  12. t:add("Refinery", nil, 12, 6, 20, 10, 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:toggleButton(p1)
  24. --# and toggle the redstone output on that side.
  25. rs.setOutput(p1, not rs.getOutput(p1))
  26. end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement