Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- EasyButton by TheGamerOfAction
- buttons = {}
- function createButtonField(x, y, mx, my, name)
- buttons[name] = {}
- buttons[name].x = x
- buttons[name].y = y
- buttons[name].mx = mx
- buttons[name].my = my
- buttons[name].name = name -- This may seem silly, but is IS necessary
- end
- function removeButton(name)
- buttons[name] = nil
- end
- function waitForClicks()
- while true do
- local _, b, x, y = os.pullEvent("mouse_click")
- for k, v in pairs(buttons) do
- if x >= v.x and x <= v.mx and y >= v.y and y <= v.my then
- os.queueEvent("button_click", v.name, b)
- return v.name, b
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment