Advertisement
neonerz

button

Mar 23rd, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. function setTable(name, text, xmin, ymin, width, height, onFreq, offFreq, bcolor, tcolor)
  2.    button[name] = {}
  3.    button[name]["text"] = text
  4.    button[name]["active"] = false
  5.    button[name]["xmin"] = xmin
  6.    button[name]["ymin"] = ymin
  7.    button[name]["width"] = width
  8.    button[name]["height"] = height
  9.    button[name]["onFreq"] = onFreq
  10.    button[name]["offFreq"] = offFreq
  11.    button[name]["bcolor"] = bcolor
  12.    button[name]["tcolor"] = tcolor
  13. end
  14.  
  15. function toggleButton(name)
  16.    button[name]["active"] = not button[name]["active"]
  17. end    
  18.  
  19. function drawButton(x, y, width, height, bcolor, tcolor, text)
  20.     m.setBackgroundColor(bcolor)
  21.     --Draw the background
  22.     for i=1,height do
  23.         m.setCursorPos(x,y+i-1)
  24.         m.write(string.rep(" ", width))
  25.     end
  26. --  m.setBackgroundColor(colors.black)
  27.     --Write the text
  28.      m.setTextColor(tcolor)
  29.     local textX = x + math.floor(width/2 - string.len(text)/2)
  30.     local textY = y + math.floor(height/2)
  31.     m.setCursorPos(textX, textY)
  32.     m.write(text)
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement