 |
chris123zugg Adept
Joined: 23 Aug 2013 Posts: 218
|
Posted: Wed Apr 30, 2025 9:16 pm
using match and a string list off a pattern match |
Player: (*) is the capture
i then need it to match the capture to the string list and do or not do something... this according to the #help file should work?
Code: |
#IF %match(%1, %ismember("%1", "@partytoons")) {} (edited)
|
any help would be appreciated, thanks in advance :P |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4764 Location: Pensacola, FL, USA
|
Posted: Thu May 01, 2025 3:16 am |
ditch all the quote marks, you only need those when passing a string, you want these values to evaluate
also, you only need %ismember, %match essentially expects a trigger pattern, which you arent providing
%match(%1, "{@partytoons}")
%ismember(%1, @partytoons)
should both evaluate as true |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
chris123zugg Adept
Joined: 23 Aug 2013 Posts: 218
|
Posted: Fri May 02, 2025 12:33 pm |
SOrry this is the capture..
Party~:(*)
#IF %match(%1, %ismember("%1", "@partytoons")) {} (edited) |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4764 Location: Pensacola, FL, USA
|
Posted: Fri May 02, 2025 12:38 pm |
That adds no new information.
You are overcomplicating things.
There is no need for you to use both %ismember and %match here.
One or the other will get the results you seek.
also, remember to wrap your expressions, and mind the wrapping characters you use, you are using parenthesis instead of curlies for your false commands
#IF (expression) {true commands} {false commands} |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
symposes Novice
Joined: 26 Apr 2006 Posts: 36
|
Posted: Fri May 23, 2025 5:08 pm |
Revisiting this, Id like to add a few things to show what was actually going on.
What I was hoping to do, was create a stringlist of names. Just the names, of the list of party members.
So I type "party" and get a read out similar to
Bob Hp: 10/10
Sally Hp: 10/10
Roger HP: 10/10
and a trigger would capture the three names and add them to a stringlist.
then When I would look id get something like
"A secluded forest.
Player: Bob the righteous.
Player: Sally the just.
Player: A knight named Roger.
"
Match worked perfect if my trigger was setup as such.
Player:%s(%*).
If %match (%1, "Bob|Sally|Roger") {}
But if i tried to do
If %match(%1, "@partylist") {}
or
If %match(%1, @partylist) {}
it would just fail to work, that is where i thought of using %ismember because if i used "Bob the righteous" as the player name in said list, it would work just fine. It was when i tried to match Bob instead of "Bob the righteous" that it became a problem.
So we were hoping to find a way to parse a string "Bob the righteous" to see Bob,and better yet "A knight named Roger" and then check it against the partylist, to see that Bob and/or Roger is indeed in our party, without having to get into a whole mess code.
And since im wobbling alot, here is the working setup i have currently,
Player~:%s(%*).
#if %ismember(%1, @partylist) {}
while the partylist variable prints as "Bob the righteous|Sally the just|A knight named Roger" |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Sat May 24, 2025 1:26 pm |
Copy and paste into the package editor
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<class name="Party" copy="yes">
<trigger priority="10" copy="yes">
<pattern>^Player:%s(*).$</pattern>
<value>#IF (%subregex(%1,"\b@partylist\b", "\1")!="") {#SAY do whatever for party members here.}</value>
</trigger>
<trigger name="PartyCap" type="Command Input" priority="20" copy="yes">
<pattern>^party$</pattern>
<value>partylist=""
#T+ EndPartyCap</value>
<trigger type="Loop Pattern" param="1000">
<pattern>^(%w) Hp %d/%d$</pattern>
<value>#ADDITEM partylist {%1}</value>
</trigger>
</trigger>
<trigger name="EndPartyCap" priority="40" enabled="false" copy="yes">
<pattern>something that marks the end of party list</pattern>
<value>#STATE PartyCap 0
#T- EndPartyCap</value>
</trigger>
<var name="partylist" type="StringList" usedef="true" copy="yes">
<json>[]</json>
</var>
</class>
</cmud> |
And to test it paste into the command line
Code: |
party
#SHOW Bob Hp 10/10
#SHOW Sally Hp 10/10
#SHOW Roger Hp 10/10
#SHOW something that marks the end of party list
#SHOW Player: A knight named Roger. |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
symposes Novice
Joined: 26 Apr 2006 Posts: 36
|
Posted: Wed Jun 04, 2025 8:39 pm |
Thank you for the example, I was able to tweak it for the mud and it captures just fine.
Though for the life of me i cannot get the player trigger to function, it always echos the true side, even with people not in the party.
I was able to write one though that used a forall loop and worked exactly like I wanted it to do.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<trigger priority="939040">
<pattern>Player~:%s(%*)</pattern>
<value>$temploop=0
#forall @partytoon {
#if %match(%1, %i) {$temploop=1} {}}
#if ($temploop==1) {#echo STAY!!} {#echo RUN AWAY!}
</value>
</trigger>
</cmud>
|
Thank you again for your help, I always appreciate seeing different ways to do things, specially when they are more efficient. |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Thu Jun 05, 2025 3:10 pm |
Sorry I am quite a bit rusty with my CMud. Properly tested this trigger for the function and left in the testing stuff so you can get a good look at it.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<trigger priority="10" copy="yes">
<pattern>^Player:%s(*).$</pattern>
<value>$test=%regex(%1, %concat("(?-i)\b(", @partylist, ")\b"), $par)
#SAY $test found $par
#IF ($test!=0) {#SAY do whatever for party members here.} {#SAY fail}</value>
</trigger>
</cmud> |
Your current trigger is quite insecure. Using the example party list the following would activate your current one:
Code: |
#SHOW Jane says ~"I think Player: Crogert is cute.~" |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
|
|