Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("down")
- local mon = peripheral.wrap( "top" )
- os.loadAPI("viewportAPI")
- os.loadAPI("buttonAPI")
- viewport = viewportAPI.new({term = mon})
- button = buttonAPI.new({
- x = 1, y = 1, width = 10, height = 1
- })
- viewport:addElement(button)
- viewport:redraw()
- function clickHandler(element, posX, posY)
- element.backgroundColor = element.backgroundColor == colors.white and colors.green or colors.white
- return true
- end
- button.callback = clickHandler
- while true do
- event, side, xPos, yPos = os.pullEvent("mouse_click")
- viewport:handleClick(xPos, yPos)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement