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?
|
You don't. You need to use a table. Sorry.
local MyLocalFuncTable = {
["toggleFunction"] = ToggleLocation
}
MyLocalFuncTable[buttonname]()
When buttonname equals the string "toggleFunction", then ToggleLocation will be called.
(I didn't quite get what your locals and globals where, so I might have mixed up their names.)