Advertisement
xbsktball10x

Untitled

Nov 30th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1.  
  2.  
  3. rednet.open("down")
  4. local mon = peripheral.wrap( "top" )
  5.  
  6. os.loadAPI("viewportAPI")
  7. os.loadAPI("buttonAPI")
  8.  
  9. viewport = viewportAPI.new({term = mon})
  10.  
  11. button = buttonAPI.new({
  12. x = 1, y = 1, width = 10, height = 1
  13. })
  14.  
  15. viewport:addElement(button)
  16. viewport:redraw()
  17.  
  18. function clickHandler(element, posX, posY)
  19. element.backgroundColor = element.backgroundColor == colors.white and colors.green or colors.white
  20. return true
  21. end
  22.  
  23. button.callback = clickHandler
  24.  
  25. while true do
  26. event, side, xPos, yPos = os.pullEvent("mouse_click")
  27. viewport:handleClick(xPos, yPos)
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement