edit:Just realized I misunderstood what you were asking. The information below might be useful if you want to improve what you created, but it will not answer your question.
__________________________________________________________________________
One more thing though, what would be the fastest way to make multiple buttons?
The easiest way would be to create a function, where you pass it arguments, and it puts it into a table. You would then have another function that loops through the table and checks to see if it is within the parameters.
Seeing as you said you have started Lua today, I will give a very short explanation of tables. Tables are basically just a box of variables. The variables can be referenced with keys, which returns the value of the variable.
short tbl examples:
Spoiler
example:
tbl = {
["key1"] = "value1",
["key2"] = "value2"
}
Here we have defined a table named "tbl" with two variables inside of it. The first variable has the key "key1" and the value "value1" in order to reference this variable you would do something like:
print(tbl["key1"]) --# prints value1
print(tbl["key2"]) --# prints value2
You can add new values to a table at anytime by doing something like:
tbl["key3"] = "value3"
print(tbl["key3"] --# prints value3
Example code:
local buttons = {} --# creating a table to hold the buttons we are going to create
local function createButton(name,startX,endX,startY,endY) --# the name is the name of the button, it needs to be a unique identifier
buttons[name] = {["startX"] = startX, ["endx"] = endX, ["startY"] = startY, ["endY"] = endY}
end
local function check(x,y)
for key, value in pairs(buttons) do --# looping through the buttons table, each iteration key is equal to the key and value to the value
if value["startX"] <= x and value["endX"] >= x and value["startY"] >= startY and value["endY"] <= endY then
return key --# key is the name. We return the name, so you know which button was pressed.
end
end
end
Example of creating and checking for a button:
createButton("button1",1,1,5,10)
createButton("button2",2,2,5,10)
check(2,6) --# returns button2
check(1,7) --# returns button1
--# example in actual use
local event, button, x, y = os.pullEvent("mouse_click")
local clicked = check(x,y)
if clicked == "button1" then
--# button1 was pressed
elseif clicked == "button2" then
--# button2 was pressed
end