You need to create two variables (IsKey, ArrayKeyToUse) to use the following code. This one is the loadvar alias. I use ^loadvar (.+?)$ in REGEX for the alias.
CODE
SetVariable("IsKey", 1)
SetVariable("ArrayKeyToUse", "")
if GetVariable("%1") == nil then
Note("That variable doesn't exist - can't load variables from it.")
else
if ArrayExists("%1") == false then
ArrayCreate("%1")
else
ArrayClear("%1")
end
for w in string.gmatch (GetVariable("%1"), "%w+") do
if GetVariable("IsKey") == "1" then
SetVariable("ArrayKeyToUse", w)
SetVariable("IsKey", 0)
else
SetVariable("IsKey", 1)
ArraySet("%1", GetVariable("ArrayKeyToUse"), w)
end -- if
end -- for
end -- original if
SetVariable("ArrayKeyToUse", "")
if GetVariable("%1") == nil then
Note("That variable doesn't exist - can't load variables from it.")
else
if ArrayExists("%1") == false then
ArrayCreate("%1")
else
ArrayClear("%1")
end
for w in string.gmatch (GetVariable("%1"), "%w+") do
if GetVariable("IsKey") == "1" then
SetVariable("ArrayKeyToUse", w)
SetVariable("IsKey", 0)
else
SetVariable("IsKey", 1)
ArraySet("%1", GetVariable("ArrayKeyToUse"), w)
end -- if
end -- for
end -- original if
The savevar alias does not require near the coding. I use REGEX of ^savevar (.+?)$ for the savevar alias.
CODE
if ArrayExists("%1") == false then
Note("Array to save does not exist - Try another.")
else
SetVariable("%1", ArrayExport("%1", "|"))
Note(GetVariable("%1"))
end
Note("Array to save does not exist - Try another.")
else
SetVariable("%1", ArrayExport("%1", "|"))
Note(GetVariable("%1"))
end
If anyone more experienced then me know of a better way then feel free to elaborate.
What I do with these is Execute("savevar Dolls") in my quit alias and on the Password correct trigger I do Execute("loadvar Dolls"). I do this with the other arrays I use as well.
