View Single Post
04/30/14, 09:47 AM   #9
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
Originally Posted by skyraker View Post
I'm trying to convert the use of a string as a function call from the global namespace to calling local functions.

Lua Code:
  1. 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.)

Last edited by Iyanga : 04/30/14 at 09:50 AM.
  Reply With Quote