Guest User

easybutton

a guest
Jul 7th, 2013
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. -- EasyButton by TheGamerOfAction
  2. buttons = {}
  3. function createButtonField(x, y, mx, my, name)
  4.   buttons[name] = {}
  5.   buttons[name].x = x
  6.   buttons[name].y = y
  7.   buttons[name].mx = mx
  8.   buttons[name].my = my
  9.   buttons[name].name = name -- This may seem silly, but is IS necessary
  10. end
  11. function removeButton(name)
  12.     buttons[name] = nil
  13. end
  14. function waitForClicks()
  15.  while true do
  16.    local _, b, x, y = os.pullEvent("mouse_click")
  17.    for k, v in pairs(buttons) do
  18.     if x >= v.x and x <= v.mx and y >= v.y and y <= v.my then
  19.        os.queueEvent("button_click", v.name, b)
  20.        return v.name, b
  21.       end
  22.     end
  23.  end
  24. end
Advertisement
Add Comment
Please, Sign In to add comment