Posted 07 July 2013 - 12:07 PM
I want to call a function via : event, button, x, y = os.pullEvent("mouse_click")
different values of y represent different functions.
the functions are declared normally:
This will probably sound confusing so here is an example of what i mean:
so something like:
i also know that for this example i could just use two if- statements to check whether the y is 1 or 2 but i want to know if this is possible in general and if you have more variables.
i appreciate any help and thank you for your time investment.
different values of y represent different functions.
the functions are declared normally:
function normal()
print("this function is declared normally")
end
i want to store the name of the function inside a tabel and then run the function via running the key as y from .pullEvent.This will probably sound confusing so here is an example of what i mean:
function a()
print("a")
end
function b()
print("b")
end
local tabel = {
[1] = a(),
[2] = b()
}
event, button, x, y = os.pullEvent("mouse_click")
then i wanna call the function via interpreting the y from .pullEvent as the key.so something like:
run tabel[y]
but i dont know how to do this. i searched almost an hour for a solution, but didnt find anything.i also know that for this example i could just use two if- statements to check whether the y is 1 or 2 but i want to know if this is possible in general and if you have more variables.
i appreciate any help and thank you for your time investment.