WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Saved Variables: Converting from Account Level to Character Level (https://www.wowinterface.com/forums/showthread.php?t=2487)

Ravendwyr 11-24-05 05:26 AM

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.

Elkano 11-24-05 06:19 AM

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?

Ravendwyr 11-24-05 06:20 AM

I changed my password after November the 8th so I can't yet :(

Elkano 11-24-05 06:27 AM

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) ^^)

Gello 11-24-05 07:04 AM

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.

Ravendwyr 11-24-05 07:42 AM

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.

Gello 11-24-05 08:09 AM

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.

Ravendwyr 11-24-05 08:17 AM

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...

Gello 11-24-05 08:34 AM

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.

DSanai 11-24-05 02:26 PM

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.

Ravendwyr 11-25-05 03:28 AM

Thanks DSanai. Much appreciated. :)

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

Elkano 11-25-05 03:54 AM

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 :)


All times are GMT -6. The time now is 11:44 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI