Advertisement
LBPHacker

The most simple Buttons API Test

Mar 19th, 2013
873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. os.unloadAPI("buttons")
  2. os.loadAPI("buttons")
  3.  
  4. local running = true
  5. local guiButtons = {}
  6.  
  7. close = function() running = false end
  8. hideme = function()
  9.     buttons.show(guiButtons.buttonSelfHiding, false)
  10.     buttons.enable(guiButtons.buttonClose, false)
  11. end
  12. makeitgreen = function()
  13.     buttons.setColor(guiButtons.buttonRed, colors.white, colors.lime)
  14.     buttons.setText(guiButtons.buttonRed, "Ahem - Problem?")
  15.     buttons.show(guiButtons.buttonSelfHiding, true)
  16.     buttons.enable(guiButtons.buttonClose, true)
  17. end
  18. gofunky = function()
  19.     buttons.setPosition(guiButtons.buttonFunky, 3 + math.random(0, 20), 9 + math.random(0, 5), 11, 1)
  20. end
  21.  
  22. guiButtons.buttonClose = buttons.register(3, 3, 7, 1, colors.white, colors.lightGray, "Close", close)
  23. guiButtons.buttonSelfHiding = buttons.register(11, 3, 10, 1, colors.white, colors.lightGray, "Hide me!", hideme)
  24. guiButtons.buttonRed = buttons.register(3, 5, 23, 3, colors.white, colors.red, "WTF? A red button?!", makeitgreen)
  25. guiButtons.buttonFunky = buttons.register(3, 9, 11, 1, colors.white, colors.yellow, "Go funky!", gofunky)
  26.  
  27. buttons.draw()
  28. while running do
  29.     local eventArray = {os.pullEvent()}
  30.     buttons.event(eventArray)
  31.     buttons.draw()
  32. end
  33.  
  34. os.unloadAPI("buttons")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement