[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Quick EnableAlias and Variable manipulation question

Quick EnableAlias and Variable manipulation question

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Zylo4   USA  (9 posts)  [Biography] bio
Date Wed 28 Mar 2012 11:16 PM (UTC)
Message
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?
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 29 Mar 2012 12:50 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Zylo4   USA  (9 posts)  [Biography] bio
Date Reply #2 on Thu 29 Mar 2012 01:36 AM (UTC)
Message
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.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


9,096 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]