Thread Tools Display Modes
09-08-07, 05:52 AM   #1
MadOverlord
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 3
How to modify SavedVariablesPerCharacter variables by "name"

I'm just getting started with LUA.

In my interface code, it would be very helpful to be able to specify a function like

Toggle_Indirect(state, "ASAVEDVARIABLE.SUBELEMENT")

that sets ASAVEDVARIABLE.SUBELEMENT to the value of state.

But code like:

Code:
function Toggle_Indirect( state, globalName )

	myPrint("_Indirect got "..tostring(state).." and ["..globalName);

	-- apply the new state to the desired global

	setglobal(globalName, state);
	
	local derf = getglobal(globalName);
	
	myPrint("_Indirect after set "..tostring(derf));

	-- and let the addon know there has been a configuration change
	
	ConfigurationChange();
	
end
Doesn't do the job. the prints indicate that a global with the right name has been set properly, but this apparently is not the saved variable, because the configuration change routine sees the old value.

What's the idiom in LUA for doing this kind of thing?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to modify SavedVariablesPerCharacter variables by "name"


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off