-
Posted by newbie on Tue, 01 Oct 2013 00:08:21
Hey all,
Right now I've got some edit boxes placed in my frame.xml and I would like the user to be able to change these values, and these values should be saved for later use.
These values also have a default string, the variables are being saved like they should, but now I'm stuck, how do I save the user input ? The documentation in the book about saved variables, tells me how to change them indeed but nothing is mentioned about updating the "new" variables.
-
Posted by jnwhiteh on Tue, 01 Oct 2013 04:34:57
I am not sure that I understand your question fully. If you've stored some saved variables and you want to know when they are loaded so you can utilise those values, you can wait for the
ADDON_LOADED
event where the first argument is the name of your addon-- that's when they are available. It's up to you to manually do whatever you want to do with those values at that point. -
Posted by newbie on Tue, 01 Oct 2013 08:58:25
I am not sure that I understand your question fully. If you've stored some saved variables and you want to know when they are loaded so you can utilise those values, you can wait for the
ADDON_LOADED
event where the first argument is the name of your addon-- that's when they are available. It's up to you to manually do whatever you want to do with those values at that point.Ok I will try to explain it better.
Let's say that saved variable is called HelloWorld, (adding the saved variable to .toc and create a table for the settings)
settings = { HelloWorld = "This is the default Hello World Message.", }
Now I have a user EditBox, where I want the user to either have that default message or their own message. It works fine to load the message and display it in the EditBox like so: ` EditBox:SetText('settings.HelloWorld'); ` Ok, so the EditBox is now showing the default value from the variable HelloWorld. Now when I try to edit the EditBox, with a diffirent message let's say "Hello New Message". Then I will see the "Hello New Message" my entire login session in Wow, but once I logout the "Hello New Message" doesn't save, in my: _WTF/Account/NAME/SERVER/CHARACTER/example.lua , I will still see the old message HelloWorld = "This is the default Hello World Message." But I want it to change to "Hello New Message".
I hope I made it more clear now :)
-
Posted by jnwhiteh on Tue, 01 Oct 2013 20:22:22
If you name the variable HelloWorld, it has to be called HelloWorld. You can't wrap it in a table, it has to exist at the name
_G['HelloWorld']
, which yours does not. That's why its not being saved. -
Posted by newbie on Wed, 02 Oct 2013 09:18:00
If you name the variable HelloWorld, it has to be called HelloWorld. You can't wrap it in a table, it has to exist at the name
_G['HelloWorld']
, which yours does not. That's why its not being saved.Sorry the forum post I made is wrong, I was writing a bit too fast, the variable in my addon is correct, it's saving fine, but you didn't answer my question, how can I overwrite the saved variable ?
-
Posted by jnwhiteh on Wed, 02 Oct 2013 18:41:16
I do not understand your question, or I've already answered it.
If you add a SavedVariable as 'MyAddonDatabase'. Once in-game, you set the value of this to something:
MyAddonDatabase = "This is a monkey"
When you reload it should be saved. You can reload and
/dump MyAddonDatabase
and should see the right value. If you're trying to display the stored value in your edit box, you need to do what I told you to, register for theADDON_LOADED
event with the first argument as your addon name. In response to that event, the value should be available and you can update the contents of the edit box.