Quick EnableAlias and Variable manipulation question

Posted by Zylo4 on Wed 28 Mar 2012 11:16 PM — 3 posts, 13,161 views.

USA #0
I'm hoping that there's a quick fix to this. With the grouping of aliases that I have presently, there are skills split up into groups. So all of my fencing skills are in a group named 'Abilities - Fencing', subtlety skills are in 'Abilities - Subtlety', thievery in 'Abilities - Thievery'... you get the idea.

Is there any way to use a EnableAliasGroup command in Lua, to enable and disable multiple groups at once, like this? Like a EnableAliasGroup("Abilities - *",false), or would I have to go through each one individually?

I have a similar deal with Variables. They can't be split into groups (so awesome if they could be), but I keep the names such that they group together alphabetically. For instance, VAULTSteel, VAULTIron, VAULTPlatinum, would be three variables used to track things in my vault. Some way to pull off a SetVariable("VAULT*",0) would be amazing.

Is there any way to do either of these?
Australia Forum Administrator #1
You could make an alias that does something like this:


al = GetAliasList()
if al then
  for k, v in ipairs (al) do 
    local group = GetAliasInfo (v, 16) 
    if group:match ("^Abilities ") then
      EnableAlias (v, true)  -- or false to disable
    end -- if
  end  -- for
end -- if we have any aliases


What that is doing is checking every alias, getting its group (alias info 16) and then doing a regexp match to see if it starts with Abilities. Ones that do are enabled. Change it slightly to disable it.

You could do something very similar with variables. Use GetVariableList to get all known variables. Test them with a regular expression (string.match). If they match the desired pattern set them to the value you want.

You might find it easier to store variables as Lua variables and just serialize them in and out when the plugin (or world) is loaded and saved. Then you can put variables inside tables, and organize them better that way.
USA #2
This is fantastic. It didn't occur to me for a minute to try doing it this way, but it should do just what I need.

Thanks for the help, Nick. As always, you're spot on.