Group member highlighting

Posted by Bradley on Thu 08 Jul 2004 09:58 AM — 5 posts, 19,191 views.

#0
I'm a bit rusty at programming so I thought I'd run the idea by you people first. Here's what I'm looking @ coding:

Upon forming a group (band/party etc), I'd type "group" to display the standard output returned from the MUD (I've cut the rest of the table off to save room):

  Member           Hits      Move   
------------------------------------
  Peter            perfect   rested   
  John             perfect   rested   
  Jill             perfect   rested  

The player names will be dumped into an array.

From then on, the name is matched and coloured so it's easy to see.

If another member joins later on, simply typing "group" again, spills out the table and renews the array with the names.

Any ideas/tips etc? If not, it's time to get to work =) The only spot where I'm a little hazy on is how to correctly grab the person's name only (from the group table).

Amended on Thu 08 Jul 2004 01:24 PM by Bradley
USA #1
Assuming the spacing of that table is correct (the forum can get troublesome), then the following regexp will work.

[ ]{2}(\w+)[ ]+(perfect|average|etc)[ ]+(rested|tired|etc)[ ]+

fill in the average/etc with the other states (seperate them with | which is shift+\ and the same for the rested things. Or replace them with (\w+). Just make sure you account for the spaces. You can read more in the Windows script doc.

To make this trigger work, you need to make sure you check the Regular Expression box. Then youll get the name with %1.

Erm, I cant figure out how to match on a variable with more than one name. I seem to remember that you could put person1|person2|person3 into a variable, and then match on that. Nick?

However, what you CAN do, is have a variable (like the one above) using setvariable (read the list of inbuilt script functions for everything you need), and then use that to delete your trigger, and add another one with an updated match for your newer group. (deletetrigger, and addtrigger) the trigger would be a regexp, repeat on the same line, and then a color change, and then the match would be (person1|person2|person3). Then you wouldnt need an array.

Nick? Help on the matching from a variable?
Australia Forum Administrator #2
See the release notes for version 3.48 ...


12. When matching a trigger which contains a variable name, you can now prevent the variable's contents from being "escaped", in case you deliberately want to put a regular expression in it. eg.

variable target = "alice|bob"

trigger match = You see (@!target) here

The "!" after the "@" tells MUSHclient to use the variable literally and not try to put backslashes in front of any meta-characters in the regular expression.



So in your case you want to put each person found into a single variable, separated by the | character, and then make the trigger match on it. Say the variable name is "friends" then the trigger will match:

@!friends

As for the rest, I would make a trigger that matches on "Member Hits Move " - this clears out the "friends" variable to be empty. Then enable another trigger that matches along the lines of what Flannel said.

Finally have a trigger that matches something else (if necessary) like the prompt line, that disables the second trigger. This might not be necessary, you could try and see.

#3
Damn am I rusty as. Had a shot of it and here's what I came out with. Used some of the idea and muddled my way through it =)

Here's the trigger:

  <trigger
   enabled="y"
   match="[ ]{2}(\w+)[ ]+(perfect|v.good|good|fair|bad|v.bad|awful)"
   regexp="y"
   script="Hilite"
   send_to="12"
   sequence="100"
  >
  <send>%1</send>
  </trigger>
</triggers>


And here's the script

sub Hilite (strTriggerName, strTriggerLine, aryWildcards)

dim temp
temp = world.GetVariable("currentmember") + "|" + world.GetVariable("friendlist")
world.note "temp atm = " + temp 
world.SetVariable "friendlist", temp
end sub


I lost you Nick on the @! bit.

Say you have a variable called friendlist with |Nick|Bradley|Flannel in it (which it is doing atm).

It sounds like by simply putting @!friendlist into the "Trigger" field when creating a Trigger in MushClient would make the trigger fire when Nick, Bradley or Flannel are mentioned.
Amended on Fri 09 Jul 2004 01:18 PM by Bradley
USA #4
You are correct. the @ means basically "this is a variable" and itll substitute in whatever the contents of the variable are. (well, assuming "expand variables" is checked) and then the ! behind it means that it treats that variable as part of your regexp. so, basically @!friendlist would, in all practical purposes, substitute in the variable, and THEN try and match.

So yes, your last trigger would be @!friendlist (nothing else needed) with regexp, keep evaluating, repeat on same line, and expand variables.

Actually, you shouldnt have your initial | it should be name|name|name and you should have parenthesis around it (either make your trigger (@!friendlist) or make the variable (name|name|name) I would assume the former would be easiest.