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
Kush
Newbie


Joined: 31 May 2016
Posts: 8
Location: Yorkshire, England

PostPosted: Sat Jun 04, 2016 1:43 am   

Automating Group Member Captures
 
Hi there guys so on previous advice I want to get abit fancy with the auto capture of my group member names.
I have had success in doing this with what I have learned by trial and error mostly.
What I have done is by no means beautiful and I run into some problems.

Trigger Text:
Leader of: ReK YoSelf
Members: pommes d'Parranoid, Pace YoSelf, Aaric, Yase Terday and Coco Loco

Trigger Pattern :
Code:
^Leader of: (*)$Members: (*)


Value:-
Code:
#VAR grouper1 %1
#var grouper2 %word( "%2", 1, ", ")
#var grouper3 %word( "%2", 2, ", ")
#var grouper4 %word( "%2", 3, ", ")
#var grouper5 %word( "%2", 4, ", ")
#var grouper6 %word( "%2", 2, "and ")

#if %ends( @grouper5, "and you") {#var grouper5 %leftback( @grouper5, 8)}
#math group6length %len( @grouper6)+5
#if (@grouper6="you") {#VAR grouper6 @mename} {#var grouper5 %leftback( @grouper5, @group6length)}


What I have done above works for 5 or 6 group members but is ghastly, I really dont fancy having to repeat the #if's and #math's for all the possible trigger texts:-

Members: you
Members: pommes d'parranoid and you
Members: pommes d'parranoid, Pace YoSelf and you
Members: pommes d'parranoid, Pace YoSelf, Aaric and you
Members: pommes d'parranoid, Pace YoSelf, Aaric, Yase Terday and you
Members: pommes d'Parranoid, Pace YoSelf, Aaric, Yase Terday and Coco Loco

If someone could point me in the right direction I would be forever in there debt. I have attempted this again and again in different ways and have achieved little bar confusing myself

Also I would like to know how to clear the other @grouperX variables if there was no information to capture

Thanks, Kush
Reply with quote
Dasyr
Newbie


Joined: 29 Jan 2016
Posts: 8

PostPosted: Sat Jun 04, 2016 9:21 am   
 
Hi Kush,

I think something like this would work for you

Code:
#trigger {Members: (*)} {#variable group {%replace(%replace(@group,", ",|)," and ",|)}}


This would allow you to easily get the length of the group with %numitems(@group) and you can loop through the group a few ways, the easiest being something like..

Code:
#forall @group {say %i is in my group.}


Just my opinion.
Reply with quote
shalimar
GURU


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

PostPosted: Sat Jun 04, 2016 1:20 pm   
 
If that is the game i think it is, there should be a command to display stats about the group and its members, which should be easier to trigger and capture from then the movement line.

As it stands though...
Code:
#TR {^Leader of: (*)$Members: (*)} {
  #variable group {%replace(%replace(%replace(%2, ", ", "|"), " and ", "|"), "you", @meName)}
  #ADDITEM group %word(%1, 1)
  #LOOP %numitems(@group) {
    #VAR %concat("grouper", %i) {%word(%item(@group, %i), 1)}
    }
  }


As for clearing the variables... either make an alias that sets them
grouper1=""
Or give them all a default value via the settings editor, check use default, and use the RESET command.
_________________
Discord: Shalimarwildcat
Reply with quote
Kush
Newbie


Joined: 31 May 2016
Posts: 8
Location: Yorkshire, England

PostPosted: Sat Jun 04, 2016 2:16 pm   
 
Thank you both for you replies, I ended up going with this;-

Code:
grouplist="%2"
#VAR grouplist %push( "%1", @grouplist)
#variable grouplist {%replace( %replace( @grouplist, ", ", |), " and ", |)}
#Var grouplist %replace( @grouplist, "you", @mename)


It achieved exactly what i needed, the values also clear if there is no capture which is great and the whole process also taught me some new skills!

Is it possible to use something similar to ^ in the "you" part of this variable so it only replaces if 'you' is at the start of the line? To stop mistakes with names like "Damn you man"?
Code:
#Var grouplist %replace( @grouplist, "you", @mename)


Yeah this is for discworld, finally got back to playing after 10years. Blast from the past!
I would love to see how you would capture and process 'group shields' and 'group status'... Its a little too much for me at the moment, the pure mass of information scares me off it abit.

Once again tho guys thank you so much for the help!

Kush
Reply with quote
shalimar
GURU


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

PostPosted: Sat Jun 04, 2016 3:31 pm   
 
I haven't played in ages, so without a glimpse of the output it is hard to say.
Off hand, I would likely use a dbVar to keep everything in one place, rather then have a slew of variables.
_________________
Discord: Shalimarwildcat
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jun 04, 2016 5:24 pm   
 
Getting into good habits about using delimiters early will save you hours of headaches later. Also I would structure the code just a little differently.
Code:
#UNVAR GroupList
#UNVAR GroupTemp
#CLASS GroupCapture
#VAR GroupList {} {}
#VAR GroupTemp {} {}
#ONINPUT "GroupCap" {^command that causes the mud to send group list$} {}
#COND {^Leader of: (*)$} {#IF (%1 <> "you") {GroupList=%word(%1,1)} {GroupList=@mename}}
#COND {^Members: (*)$} {
 GroupTemp=%replace(%replace("%1", ", ", "|"), " and ", "|")
 #FORALL @GroupTemp {
  #IF (%i <> "you") {#ADDITEM GroupList {%word(%i,1)}} {#ADDITEM GroupList {@mename}}
 }
}
#CLASS 0
To describe what it all does:
First it deletes any existing occurrence of the variable, avoiding variable name conflicts can be important and can be a nightmare to track down.
Next it creates a class to put everything in so it stays nice and tidy.
Then it creates the variables, and sets them to have defaults of empty values. They will automatically be set to empty on load, and you can use the #RESET command to empty them at other times that might be convenient.
Next is a multi-state trigger. The first state activates based on the command you enter, and you will have to update it with correct information. The other states become active sequentially as each state occurs. Using this method becomes important as the number of triggers you have grows because it results in the fewest patterns being tested against each line from the MUD and the best speed.
Finally the command #CLASS 0 tells zMud to stop adding things into the class.

Note the line: GroupTemp=%replace(%replace("%1", ", ", "|"), " and ", "|")
If you upgrade to CMud then that would have to be changed to: GroupTemp=%replace(%replace(%1, ", ", "|"), " and ", "|")
It is a quirk of how zMud handles captured information that can cause it to interpret that captured text the same as script you wrote. For this reason the * pattern does not capture some characters that could cause problems. CMud does not have this risk.

There is no perfect way to cover people using "and" in their name and that is an example of why I fully support the Oxford Comma. Also if people can use a comma in their name it will cause similar problems. The only way to totally cover those potentials is to record bad names and specially replace them earlier in the capture.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
shalimar
GURU


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

PostPosted: Sat Jun 04, 2016 8:05 pm   
 
From there you can add vitals via

temp=%db(@groupList, Pace)
#ADDKEY temp TPA {some value}
#ADDKEY GroupList Pace @temp

#SAY @GroupList.Pace.TPA
_________________
Discord: Shalimarwildcat
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