Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Jaferg
Newbie


Joined: 11 Oct 2016
Posts: 6

PostPosted: Tue Oct 11, 2016 9:19 pm   

Please help
 
Hi guys I am new to zmud, so consider me clueless.

I am trying to set up an alias (getgroup) that will make a trigger to fill a variable (groupmember) with all members of my group, fire the group command in game and then delete the trigger.
The following text is what shows when using the group command in game and the variable will need to store at least 5 names.

Code:
  Member              Hits      Move      Position  Fly Inv Water iMT Here Light Mem
------------------------------------------------------------------------------------
  CL Jaferg           v.good    rested    standing   Y   Y    N    Y   Y     1    0


The following is the prompt text if you need something to trigger off after the group command is sent:
403H 100V 6123456X 78.56% 1461C Exits:D>

I will then use the groupmember variable in a set of triggers for rescuing my groupmembers.

Example of combat text is :

%1 (massacres|annihilates|obliterates|mutilates) &groupmember with (his|her|its) (slash|sting|pierce|crush|bludgeon|hit|smite|cleave|stab).

I want this trigger to fire rescue command but then to disable itself until the rescue attempt has been made. The following example of combat shows how mobs can attack multiple times in a round and I dont want to be firing multiple rescue attempts in one round.

&groupmember flies in from the south.
Nulph Glug slashes &groupmember extremely hard.

403H 87V 6151327X 78.05% 2641C [**&groupmember:Fair**] [**Nulph Glug:Awful**] Mem:1 Exits:S>

Nulph Glug massacres &groupmember with his slash.
&groupmember wavers under Nulph Glug's mighty slash!
Nulph Glug massacres &groupmember with his slash.
&groupmember pierces Nulph Glug very hard.

403H 87V 6151327X 78.05% 2641C [**&groupmember:Fair**] [**Nulph Glug:Awful**] Mem:1 Exits:S>


I will also be making a trigger off a room description like the following text:

%1 is (sitting|standing) here, fighting &groupmember.

and multiple aggressive skills used on &groupmember.

Any help or advice appreciated...
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Oct 12, 2016 1:10 am   
 
First let's make sure. You are using zMud and not CMud. There are many differences and given all the years I am not sure I remember them all.

In general for both you want to use an #ONINPUT trigger instead of an alias to start your group capture. This is because the trigger only needs to clear some variables and can let the command pass unchanged. By creating a sub state for that trigger it will automatically become active allowing the capture to proceed. I tend to use a LoopLines sub state and parse all the information with script for each line. %begins, %ends. %match, and %regex are your friends here. From what you said I would likely use %ends and the ">" to detect when to stop capture and parse all the lines with %subregex, because there is a solid speed gain. However, %subregex was originally buggy and I don't remember when it got rewritten to be stable.

As for sending the rescue command you want your trigger to check #IF %ismember on a variable for a groupmeber and #ADDITEM when it sends the command. Add a second trigger for doing the rescue to #DELITEM.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Jaferg
Newbie


Joined: 11 Oct 2016
Posts: 6

PostPosted: Wed Oct 12, 2016 8:42 pm   
 
Hi Vijilante, thanks for your response. I am using zmud.

You have pointed me in the right direction, but total beginner here with zmud.

Should I be inputting this from the command line? Or should I go into the trigger menu?

Could you give me an example of what it should look like?

All help appreciated, thanks again
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Oct 13, 2016 10:07 am   
 
In general you will want to build settings using the editor, but most things passed around on the forum are design to be placed directly in the command line.

Let's start with capturing the group member names.
Code:
#CLASS GroupCapture
#VAR GroupMembers {} {}
#ONINPUT "GroupCap" {^group$} {GroupMembers=""}
#COND {-*} {} {regex}
#COND {(.{22})} {#IF (%begins("%1", " ") {#ADDITEM GroupMembers {%trim("%1")}} {#STATE GroupCap 0}} {looppat|param=100|regex}
#CLASS 0


Next we want the rescue trigger, but you didn't provide an example of what a rescue attempt looks like.
Code:
#TRIGGER {* {massacres|annihilates|obliterates|mutilates} (*) with {his|her|its} {slash|sting|pierce|crush|bludgeon|hit|smite|cleave|stab}.$} {#IF (%ismember("%1", @GroupMembers)) {rescue "%1"}}
#COND {something indicating rescue was attempted} {} {duration|param=10000}


Some general notes about trigger patterns: you shouldn't use %1 in the pattern, zScript does not support nesting alternation {for|{a|big}|example} if you want to do that you have to use a regex, while the Pattern Matching page goes into a lot of detail about using &varName in patterns I don't generally recommend it as it can make reading your code hard, the * wildcard will not match certain characters in order to protect scripts.

You may notice that %1 is often put in quotes in the script I wrote. zMud used a script interpreter that filled in %1 then executed the script which means that having something like a comma in your captured data could cause a script to fail without the quotes; CMud uses a compiled script parser and does not have this weakness and more logically treats "%1" as a literal string.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Jaferg
Newbie


Joined: 11 Oct 2016
Posts: 6

PostPosted: Fri Oct 14, 2016 4:10 pm   
 
Thanks for your help Vijilante. I inputed the groupcapture code directly into the command line but it is not working. When I input group it doesn't fill the variable. Do I need to add something to the code?

^s+(TH|BA|CL|PA|WA|SC|WH|BL|RE|DA|SH|DR)s+(%1)

Or something like that for it to capture the name accurately?
Reply with quote
Jaferg
Newbie


Joined: 11 Oct 2016
Posts: 6

PostPosted: Sat Oct 15, 2016 11:47 am   
 
ok I got the errors sorted and it all fires correctly but it captures the wrong string. fills the variable with members. Could you explain what the first #cond does? Going to adjust the second #cond to a regex I think...
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Oct 15, 2016 2:06 pm   
 
The first state(0) is the input trigger which catches that you typed group. It just clears the variable and sets the stage.
The next state (1) is simply meant to match the line "------------------------------------------------------------------------------------" so that we know the next line will start having group members. Perhaps a better pattern would be ^-+$ or maybe ^-{20,}$
The third state (2) uses a fixed width match to capture a portion like this
Code:
"  CL Jaferg           "
The script there is checking for the first character to be a space and when it is it uses %trim to take all the spaces off and then places what is left into the GroupMembers variable. When it is not a space it resets the entire thing.

If I am following what you are saying as a pattern then instead of %trim("%1") you want %word("%1", 2). I am pretty sure it will eliminate the need for %trim, but if you find it necessary you can nest %word(%trim("%1"), 2).
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Jaferg
Newbie


Joined: 11 Oct 2016
Posts: 6

PostPosted: Sat Oct 15, 2016 9:15 pm   
 
So I changed the first #COND to ^-+$ and the second to #COND {^\s+(TH|BA|CL|PA|WA|SC|WH|BL|RE|DA|SH|DR)\s+(\w+)} {#ADDITEM GroupMembers {%2}} and it is now capturing names in the string. I had to take out the #state though because with it in it would only capture one name in the variable. I tried adding a third state #COND {^.*>$} {#STATE GroupCap 0} but my pattern would not match the command prompt.

403H 87V 6151327X 78.05% 2641C [**&groupmember:Fair**] [**Nulph Glug:Awful**] Mem:1 Exits:S>

It all seems to work fine without this addition anyway though. Is it necessary to reset the state to 0? It seems to automatically start from state 0 everytime I hit group. If there is benefit to using #state perhaps you can help me regex the command prompt?

Thanks again for all input, getting things moving now...


Last edited by Jaferg on Sun Oct 16, 2016 10:46 am; edited 1 time in total
Reply with quote
Jaferg
Newbie


Joined: 11 Oct 2016
Posts: 6

PostPosted: Sun Oct 16, 2016 10:43 am   
 
Fixed previous post, disregard this Rolling Eyes
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3514
Location: Pensacola, FL, USA

PostPosted: Sun Oct 16, 2016 2:19 pm   
 
Its because the third state is of type {LoopPat|Param=100}
Though since he only wants to capture 5 names, 100 seems a bit excessive.

Essentially it will stay in the third state for 100 lines.
#STATE 0 forces it to go back to the first state early (when error checking shows that this line is not a match for the group member).
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Oct 16, 2016 6:11 pm   
 
With a Loop Pattern trigger it will stay in that state until it matches the pattern the specified number of times. Again the best system is to use the fixed width pattern that checks for what it wants. All you need to do is change the %trim function to %word or add the %word function.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Wispond
Newbie


Joined: 29 Oct 2016
Posts: 1

PostPosted: Sat Oct 29, 2016 2:36 pm   
 
thanks guys. a bit more time and I was ready to take some pills just not to sleep and find what I need but thanks to your answers I found what I needed :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net