Reply
Thread Tools Display Modes
Unread 11-24-05, 05:26 AM   #1
Ethan Centaurai
A Flamescale Wyrmkin
 
Ethan Centaurai's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 135
Question Saved Variables: Converting from Account Level to Character Level

Hello,

Is it possible to convert data saved in the account level SavedVariables folder
(World of Warcraft/WTF/Account/<account>/SavedVariables)

to the character level SavedVariables folder
(World of Warcraft/WTF/Account/<account>/<realm>/<character>/SavedVariables)

without losing any saved data in the process?

Do I just change
## SavedVariables: <data>
to
## SavedVariablesPerCharacter: <data>
or is there some sort of special code I need to add?

Thanks in advance.

- D.I.
Ethan Centaurai is offline   Reply With Quote
Unread 11-24-05, 06:19 AM   #2
Elkano
A Flamescale Wyrmkin
 
Elkano's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 119
I don't know it for sure but the way you posted sounds as it would work.
The addon loads it's normal per account file on load and on shutdown it writes it per character.
Since I don't think it will only load those variables noted in the toc there shouldn't be any problem.
But why don't you simply test it on the test realm?
Elkano is offline   Reply With Quote
Unread 11-24-05, 06:20 AM   #3
Ethan Centaurai
A Flamescale Wyrmkin
 
Ethan Centaurai's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 135
I changed my password after November the 8th so I can't yet

Last edited by Ethan Centaurai : 11-24-05 at 06:22 AM.
Ethan Centaurai is offline   Reply With Quote
Unread 11-24-05, 06:27 AM   #4
Elkano
A Flamescale Wyrmkin
 
Elkano's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 119
I haven't enought disc space atm so I can't test for you either
(but I think I'll make some over the we, so maybe I'll look into it... can't wait to test a md5 implementation (using bitlib) ^^)
Elkano is offline   Reply With Quote
Unread 11-24-05, 07:04 AM   #5
Gello
A Scalebane Royal Guard
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 435
If you make that .toc change and then copy the file from the main SavedVariables folder to your characters' SavedVariables you won't lose any data.

However:
- changes to the toc aren't seen until you completely shut down, exit WoW to desktop. So if you change ## SavedVariables to ## SavedVariablesPerCharacter, it won't have any effect until you next start WoW up from desktop.
- When it does log in, it won't see the character-specific SavedVariable, so the mods will create default ones.
- Copying the main SavedVariables to character-specific while in game will be ignored.
- The old main SavedVariables remains in the SavedVariables folder. So you can copy it to character-specific folders if you want to copy settings.

I really hope more mods use it. I prefer all my settings to be the same across all characters.

From a mod-creation view, the change is completely transparent. There's nothing that needs worked around. But if you break a piece away from a table to the per-character tag, you can use the above to your advantage and have a "default" that was the user's setup prior to the switch.
Gello is offline   Reply With Quote
Unread 11-24-05, 07:42 AM   #6
Ethan Centaurai
A Flamescale Wyrmkin
 
Ethan Centaurai's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 135
So there's no easy conversion code then?
Just edit the TOC whack the SavedVariables file in the character folder and that's it?

That's exactly what I fear.

At the moment, my layout in my SavedVariables file looks like this:
Code:
tf_user_data = {
 [server1] = {
  [player1] = {
   <stuff here>
  },
  [player2] = {
   <stuff here>
  },
 },
 [server2] = {
  [player1] = {
and so on in the account level SV folder. I want it so all this data is ported over to the character folder, so it looks like this:
Code:
tf_user_data = {
 <stuff here>
},
Other people use my project and as not all of them are computer/code savvy I fear that something will go wrong. I don't want to have to make them edit the files to use the new system.
__________________

Twitter | Blog
Ethan Centaurai is offline   Reply With Quote
Unread 11-24-05, 08:09 AM   #7
Gello
A Scalebane Royal Guard
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 435
Oh yeah unfortunately mods can't put stuff into other character's folders.

If your information saves per-character now, you could add an option to make global data someplace. To give the user the option from within your mod instead of the .toc. That's not too hard to do:

user = UnitName("player").." of "..GetCVar("realmName")
-- immediately after getting the user check if they want global and substitute a global name
if tf_user_options.Global then
user = "Global of AllServers"
end

But then "Global of AllServers" would have default settings. So not an ideal solution either but it's one approach.
Gello is offline   Reply With Quote
Unread 11-24-05, 08:17 AM   #8
Ethan Centaurai
A Flamescale Wyrmkin
 
Ethan Centaurai's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 135
Hmm... well that is one way of doing it...

So at the moment it looks like converting from account to character (without manual change by users) isn't possible.

I'll keep your idea for future reference, Gello, but I'd still rather have my mod save variables per character.

Can someone be so kind as to ask Slouken if something like this is/will be possible? As I am an enGB client I can't ask him myself...
__________________

Twitter | Blog
Ethan Centaurai is offline   Reply With Quote
Unread 11-24-05, 08:34 AM   #9
Gello
A Scalebane Royal Guard
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 435
Sure tho being Thanksgiving he may not see it today. Or maybe the slower speed of the forum today will help hehe

edit: hmm in the posting it occured to me. Is this asking that when you do ## SavedVariables to ## SavedVariablesPerCharacter you want to copy over the existing SavedVariables to all character folders? This would have to be every pre-split character's data in every character's folder. The game would have no idea how to split a table apart using arbitrary keys (character and realm name).

edit2: and what do you do when a user goes from ## SavedVariablesPerCharacter to ## SavedVariables. This can't be done while logged in, so the game would need to choose one character to be the global one if it copies back?

The more I think about it the more I think a better solution would be to make a new table: tf_peruser_data, and then pull defaults out of tf_user_data in a mod's initialization. This wouldn't be overly hard and it would allow users to switch back and forth from global to per-character from the toc only.

Last edited by Gello : 11-24-05 at 08:46 AM.
Gello is offline   Reply With Quote
Unread 11-24-05, 02:26 PM   #10
DSanai
A Wyrmkin Dreamwalker
 
DSanai's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2005
Posts: 50
Actually, it is possible.

Add the ## SavedVariablesPerCharacter line, but give it a NEW variable name.

Change all the references to the old variable to the new name in the LUA/XML.

In the VARIABLES_LOADED event, do this:

if (oldVar[index]) then newVar = oldVar[index]; oldVar[index] = nil; end

[index] would be the Char/Server name set you use to distinguish between character settings in the global SV file.

Now all the old data will be saved to the new variable set, the old settings will move over, and it won't harm the settings for the other characters. Once they've all been logged in, all of the data will be migrated.

It'll still save a nil Account-level SV file, but after some time, you can probably remove that old ## SavedVariables line safely, as your users will have migrated all their commonly played characters.

Hope this helps.
__________________
Dsanai - nElf Hunter
Glacialfox - nElf Death Knight
Evilianti - Gnome Warlock
DSanai is offline   Reply With Quote
Unread 11-25-05, 03:28 AM   #11
Ethan Centaurai
A Flamescale Wyrmkin
 
Ethan Centaurai's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 135
Thanks DSanai. Much appreciated.

I'll give this a shot as soon as I can.
__________________

Twitter | Blog
Ethan Centaurai is offline   Reply With Quote
Unread 11-25-05, 03:54 AM   #12
Elkano
A Flamescale Wyrmkin
 
Elkano's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 119
I just noticed that my argumentation had a weak spot anyway...
It would have saved all data in the savedvariables of the first chara you log in with so the information fort the other charas wouldn't have been accessable any more :/
But I think there is now way bsides renaming either the new or the old variable os the way DSanai suggested should work as expected
Elkano is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » Saved Variables: Converting from Account Level to Character Level

Thread Tools
Display Modes

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