|
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Sun Aug 26, 2007 9:53 pm
Help with a trigger set involving arraylists. |
This is what the group command outputs:
Code: |
Leader: Vlad
Hits Energy Moves Exp
---- ------ ----- ---
[ 76 Ran Orc L ] Vlad 1231/1310 422/422 315/328 12322935
[ 75 Mob Fel ] Sabrina 751/751 268/268 302/302 0
[ 41 Cle Vyn ] Bartalbe 392/418 523/668 149/149 16591438
[ 70 Ran Hum ] Kimalthea 1013/1013 538/538 331/331 175969906
[ 25 Mon Vyn ] Grong 312/331 246/274 124/124 870068
[ 57 Thi Gob ] Squiurt 785/785 178/201 275/275 30468291
[ 76 Mon Trl ] Groob 998/998 248/747 246/246 239665868
|
What I'd like to do is see an example of the cMud way of adding the names to an array list, so that I can rescue them if someone leaps to attack them, and also grab their hp, so that I can see who's low on hit points.
With just one example I should be able to figure out the other stuff I need to do. Thanks in advance if anyone can help me out with this. I had one working on zMud, but I wanted to see if I got it wrong then too. (there's got to be a better way than what I did). |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Aug 26, 2007 10:13 pm |
In CMUD, arrays are a special kind of list for use with COM. What you want is a string list.
Try this:
#trig {^~[ %d %w %w {L| } ~] (%w) %s %d/%d %s %d/%d %s %d/%d %s %d$} {#additem PartyMembers %1}
This looks a lot more complex than it is because of the pattern. Basically, it matches the line, and captures the name, adding it to the list. You could have an alias to send whatever command makes the list show that turns the trigger on or something, or just leave it on all the time. Up to you.
Once this trigger's captured your party members, you can use the @PartyMembers variable with #forall or %expandlist to show your party members or do things to them, and so on. |
|
|
|
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Sun Aug 26, 2007 10:24 pm |
awesome, thanks. is there something like a hash in zmud, where I have the key (the party member name) and the value (their hp)? I'd like to be able to target a cure spell on the person if their hp is below a certain point also.... or I guess I could do that by having an if statement based on %6 or something. Also, what happens in the event of a multiple name character? should I do a {(%w)|} after the (%w) for the name then?
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Aug 26, 2007 10:35 pm |
Yep, it's called a data record variable. Take a look at #addkey.
Personally, I'd put the #ifs that check people for curing in an alias, and run it once the trigger's captured your whole party. That way you'll have the latest HP values.
About the %6 thing - that pattern only has one capture, the person's name (anything in brackets is captured). If you want other captures, put brackets round them too.
And if people can only have two names, adding {%w|} will probably be the best way, yes (note that it doesn't have brackets - we're not interested in their last name, so we don't save it). If they can have more than two names, either add [a-zA-Z ] or * instead. |
|
|
|
|
|