View Single Post
04/30/14, 11:55 AM   #10
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
Originally Posted by Harven View Post
So the toggleFunction is something like this? :
Lua Code:
  1. toggleFunction = "local arg = (select(1,...)) if arg == something then return 'ToggleLocation' elseif arg == somethingelse then return 'ToggleFPS' else return 'ToggleSomething' end"
No. It is simply toggleFunction = "Toggle"..lblName

Originally Posted by Iyanga View Post
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.)
Yeah, in the end I think I will need to go to some sort of global table if I want to keep the functions local. Not quite in this way if what I am reading is correct. I would still like to dynamically change what comes after Toggle on each iteration if I can help it because it keeps the code concise.
  Reply With Quote