ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Released AddOns (https://www.esoui.com/forums/forumdisplay.php?f=170)
-   -   update character variable on all chars at once? (https://www.esoui.com/forums/showthread.php?t=10739)

sinnereso 11/15/23 07:06 PM

update character variable on all chars at once?
 
Looking for a way to update char saved variables all at once while logged into only one toon.

I'm currently running mostly an account wide setup but have a few char specific variables id like to reset at server daily reset. I'm currently saving the per char variables like this:
Code:

ZO_SavedVars:NewAccountWide( MyAddon.svName, MyAddon.svVersion, GetUnitName("player"), defaultSavedCharVars )
MyAddon.charVariables.myvariable = something

what Id like to use is something like this to go through every character on account and set a specifici char variable at daily login which I have the code for already I'm just unsure how to save a char variable for a toon your not logged into:
Code:

function MyAddon.ResetCharacterData()
        for i = 1, GetNumCharacters() do
                local charName = GetCharacterInfo(i)
                charName = charName:sub(1, charName:find("%^") - 1)
                MyAddon.charVariables.charName.myvariable = something
        end
end

Basically in short I'd like to cycle through all characters on acct with a for statement resetting 2 char variables to 0 at daily reset time. Any suggestions?

Baertram 11/16/23 03:01 AM

SV is a global table with the name you specify at the txt file per ## SavedVariables: <globalName>

So your can read your sv file on the disk and you see the contents like
<globalName> = {
["@AccountName"] = {
["Charactername here"] = { ....


Just update it like this then:
<globalName>["@AccountName"]["Charactername here"]["variableName"] = xyz

sinnereso 11/16/23 03:15 AM

Quote:

Originally Posted by Baertram (Post 48925)
SV is a global table with the name you specify at the txt file per ## SavedVariables: <globalName>

So your your sv file on the disk and you see the contents like
<globalName> = {
["@AccountName"] = {
["Charactername here"] = { ....


Just update it like this then:
<globalName>["@AccountName"]["Charactername here"]["variableName"] = xyz

I have accountwide and character variables already set up.. I guess what I'm asking is is it possible to edit "char1" char variable from "char2" and how?

my variables are setup like this:
Code:

MyAddon.savedVariables = ZO_SavedVars:NewAccountWide( MyAddon.svName, MyAddon.svVersion, nil, defaultSavedVars )
MyAddon.charVariables = ZO_SavedVars:NewAccountWide( MyAddon.svName, MyAddon.svVersion, GetUnitName("player"), defaultSavedCharVars )

is it possible to do a "MyAddon.charVariables.something = something" to save something on each characters variables from a single character?

Baertram 11/16/23 03:50 AM

Please re-read what I described above!
I'm not talking about your ZO_SavedVars wrapper which you're already using. I'm talking about "global tables" in lua code!
The ZO_SavedVars wrapper just handles the GetDisplayName() to get your @AccountName and GetCurrentCharacterId() to get the characterId for you and then updates the "global SV able of your addon, specified at ## SavedVariables: <globalTableName>" for you.
But <globalTableName> can be read and changed directly too!

Try /tbug <globalTableName> and you see your SV table in merTorchbug.
Try /tbug MyAddon.charVariables to see the difference where ZO_SavedVars was used as a wrapper around the table.

Check your SV file on the disk to get the correct table name, subtables etc. and then simply access it like described, directly, without ZO_SavedVars usage or any pointer variable like your MyAddon.charVariables or MyAddon.savedVariables

You can do both: With ZO_SavedVars and without, even at the same addon.

sinnereso 11/16/23 05:16 AM

TY and I have been re-reading it. But.. Ive decided to revert back to a simple single acct wide variable. TY for all the help :)


All times are GMT -6. The time now is 09:12 PM.

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