Originally Posted by skyraker
I'm trying to convert the use of a string as a function call from the global namespace to calling local functions.
Lua Code:
buttonname:SetHandler( "OnClicked" , function() _G[toggleFunction](buttonname) end)
How do I make this same call of toggleFunction without those functions being global? For example, toggleFunction ends up being ToggleLocation, but I have local function ToggleLocation?
|
I really wonder why do you not use Seerah's suggestion:
Originally Posted by Seerah
Why aren't you just doing
Lua Code:
buttonname:SetHandler("OnClicked", toggleFunction)
|
I'm not a programmer, but as far as I know handler will receive "self" (that is what you call "buttonname") as a default argument.
I you really want to use function(), I believe it should have defined argument:
Lua Code:
buttonname:SetHandler( "OnClicked" , function(buttonname) toggleFunction(buttonname) end)
or because default argument is "self":
Lua Code:
buttonname:SetHandler( "OnClicked" , function() toggleFunction(self) end)
Correct me if I am wrong.