You are not logged in.

1

Wednesday, September 9th 2015, 10:41am

how to savevariables per toon?

I have an addon which saves settings in the main savevariables.lua, but it would much more make sense if each toon had separate settings. I could modify it to save a map of settings with a key being a toon name. But it smells like a workaround. We have already savevariables.lua in each toon's folder. I tried to look at some addons which seem to use it, but I still don't get it.

Any hints? Could you push me in the right direction?
* what would be the steps needed to change code saving variables in the global file to saving in a per-toon file?
* what happens with loading, how to get the values back?
* if there are two separate load-variables type events, is the order in which they happen fixed?
>>>> >>>> >>>>
>>>>
>>>> Please, bring back (bound if there is no other option) dias to AH! :thumbsup:
>>>> If you do this we will all love you forever. ;)
>>>>
>>>> >>>> >>>>

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

2

Wednesday, September 9th 2015, 11:28am

Use SaveVariablesPerCharacter("variableName") instead.

Works the same way as SaveVariables(). The only difference is the location it saves things to.
2013... The year from hell....

3

Thursday, September 10th 2015, 1:40am

Cool.

I can see this now e.g. in zBag:

Source code

1
2
3
		--save both per character, and generically so alts will have a preset
		SaveVariablesPerCharacter("zBag_VAR");
		SaveVariables("zBag_VAR");
So on the first toon nothing is set; when you log out zBag_VAR is saved in both savevariables.lua: when you log on a different toon, the perCharacter is empty so you will see the "main" value; if you change settings they will be saved both for the new char and in the main settings; for the first character it won't matter anymore - I guess, his perCharacter is loaded last and overwrites the one from the main settings (is this a guaranteed rule?). But when logging in on a yet another new character you will see the just updated main settings. Nice mechanism. :)

Can I clear a variable by simply setting it to nil before a call to SaveVariablesPerCharacter()?

The "per character" is in fact "per character name", right? If you have two toons with the same name on two servers, they will share (and overwrite) each others "per-character" savevariables and other config files, right?
>>>> >>>> >>>>
>>>>
>>>> Please, bring back (bound if there is no other option) dias to AH! :thumbsup:
>>>> If you do this we will all love you forever. ;)
>>>>
>>>> >>>> >>>>

4

Thursday, September 10th 2015, 2:52am

The "per character" is
in fact "per character name", right? If you have two toons with the
same name on two servers, they will share (and overwrite) each others
"per-character" savevariables and other config files, right?

Yes.
Rovie wd/w/s/
Fiddydamage c/r/wl/p/m
Corruption
Artemis
https://www.youtube.com/channel/UCvw3IXqDgHoaK0lHJnyqBJQ vids of stuff

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

5

Thursday, September 10th 2015, 11:40am

The location where RoM stores the "per-character"is My Documents/Runes of Magic/CHARACTER_NAME/SaveVariables.lua.

Since there is no information on which server the character is on, yes it would likely overwrite things for same name characters.

To get around this, you could setup your saved variabke to include the server name. Use GetServerName() for this.

example:

Source code

1
MySaveVar[GetServerName()] = put whatever stuff you need here

Now when you use SaveVariablesPerCharacter("MySaveVar"), things are seperated by server name.

The drawback to this is that you still need to keep all info for all other possible characters in memory. But in practice, this won't happen a whole lot so not too bad.
2013... The year from hell....