View Single Post
09-16-11, 03:01 PM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by taurouset View Post
I have two tables: CC_Vars and CC_Defaults. Both have two tables in them: Data, and Options.

Then I have a button, that calls a function, that does this: CC_Vars.Options = CC_Defaults.Options; as well as a function that does: CC_Vars.Data = CC_Defaults.Data;

The problem is, this only works once. I've tested as much as I can think of, and no matter what I do, this only works the first time I click the button, then it won't work anymore. I've made it so the function posts a message in the chat log, so I know the function is firing.

This doesn't make any sense to me. The only thing I can think of is CC_Defaults.Options could be changing somewhere, but I've checked and checked and CC_Defaults is constant.

EDIT: I just discovered my using a /script to output the data in CC_Defaults, and it turns out it is changing. But there is nothing in my code could do that!?
I also had a similar problem .. I was thinking that, maybe instead of being "copied", both variables would just point to the same table (which is located on memory address X)

So the table of variable1 would get discarded, and you'd then instead be using the table of variable2 (defaults)

Would this work?
Code:
for k, v in pairs(CC_Defaults.Options) do
	CC_Vars.Options[k] = v
end

for k, v in pairs(CC_Defaults.Data) do
	CC_Vars.Data[k] = v
end

Last edited by Ketho : 09-16-11 at 03:07 PM.
  Reply With Quote