Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Lua Beginner

Lua Beginner

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


Pages: 1  2 

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #15 on Thu 01 Apr 2010 09:48 PM (UTC)

Amended on Thu 01 Apr 2010 09:51 PM (UTC) by Nick Gammon

Message
Yes you are on the right track. Combined with a bit of table handling. This should do it:


<aliases>
  <alias
   match="show_groups"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

local tl = GetTriggerList()
if not tl then
  print "No triggers"
  return
end -- if

local groups = {}

-- work out which ones enabled 

for k, v in ipairs (tl) do

  local group = GetTriggerOption (v, "group")
 
  -- create table entry for this group first time around
  groups [group] = groups [group] or { enabled = 0, disabled = 0 }
 
  if GetTriggerOption (v, "enabled") == 1 then
    groups [group].enabled = groups [group].enabled + 1
  else
    groups [group].disabled = groups [group].disabled + 1
  end -- if

end -- for

-- show results, per group

for k, v in pairs (groups) do
  ColourTell ("white", "", string.format ("%%15s: ", k))
  if v.enabled &gt; 0 then
    ColourTell ("green", "", string.format ("%%i enabled ", v.enabled))
  end -- if
  if v.disabled &gt; 0 then
    ColourTell ("yellow", "", string.format ("%%i disabled ", v.disabled))
  end -- if
  Note ""  -- new line

end -- for

</send>
  </alias>
</aliases>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


A whole group is not necessarily enabled (so this alias shows, per group, how many in that group are enabled and how many disabled).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by AaronM86   (42 posts)  Bio
Date Reply #16 on Thu 01 Apr 2010 10:18 PM (UTC)
Message
Ah, excellent! I had attempted to set this up all morning lol, kept running into a bit of trouble. I see what I was doing wrong now. Thanks :D Appreciate it a ton.
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.


58,251 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

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

Go to topic:           Search the forum


[Go to top] top

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