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
jluce7
Beginner


Joined: 20 Dec 2005
Posts: 22

PostPosted: Mon Jan 23, 2006 2:35 am   

Multiple capturing of names
 
I am trying to set something up and need to know how to capture information from the output. Again, this is for Achaea.

If I type BW or QW it tells you who is on line. Typically there are about 2-400 people on but it lists them all (unless they have an artifact that removes them from the list). What I want is a setup that is in a class. I activate this class, type BW, and it checks various info on the person. Iwant to make a list of who is on, from what city, etc.

A typical BW line looks like:
Johnny, Tommy, Sam, Pam, Jan, Joey. Soandso,
(goes on for about 20 lines usually)

The lines don't always have a comma on the end, and vary in length depending on the length of the characters names. I was looking for a way to make it capture Johnny....do the checks I need, reset and capture Tommy...do the test, rinse/repeat. Anyone know a way I can make this happen? Would be hugely appreciated.!!! THanks
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Mon Jan 23, 2006 6:33 am   
 
What do you see before those 20 lines and after those 20 lines to make boundaries for the trigger.
Reply with quote
jluce7
Beginner


Joined: 20 Dec 2005
Posts: 22

PostPosted: Mon Jan 23, 2006 1:19 pm   
 
The prompt is the only thing I see right before and right after. Mine looks like this: with a space before the names, and one after...

3192h, 1878m ex-

So I would assume something like {(%d)h, (%d)m, *-} would work for boundaries. So it would show:

3192h, 1878m ex-

Johnny, Tommy, Sam, Pam, Jan, Joey. Soandso,
everyone, else,

3192h, 1878m ex-
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Mon Jan 23, 2006 2:13 pm   
 
#ONINPUT "qwtrig" {qw} {~qw;#VAR qw %null;#TEMP {(%d)h, (%d)m, *-} {#STATE qwtrig 0;#VAR qw %replace( %replace( @qw, "||", "|"), " ","");#NOOP Process here}} "" {notrig}
#COND {^(*)$} {#VAR QW %concat( @QW, "|", %replace( {%1}, ",", "|"))} {looppat|param=999}

How about something like that.

The trigger starts when qw is entered.
It then captures all the lines till it sees your prompt making a stringlist called qw.
The processing happens when it sees your prompt.
a) it takes out %null lines that it might catch after the command and before your prompt if there are spaces.
b) it takes out any spaces in case there might be some at the end of lines or after commas
Then you should be able to go through the cleaned contents of @qw to do your checks.
Reply with quote
jluce7
Beginner


Joined: 20 Dec 2005
Posts: 22

PostPosted: Mon Jan 23, 2006 3:28 pm   
 
I tried this and it kept the blank space between the time I hit QW and the time ot displayed, then captures the first name of each line in QW (including my prompt). the @qw variable looks like this..

2968h, 1818m ex-qw

Johnny, Joey, Tommy, Slim, Paul,
Beavis, Butthead, Jones, Ricky,
Sam, Pam, Jan
2968h, 1818m ex-

@QW looks like this:
1:
2: {2968
3: {Beavis
4: {Sam
5: {

How do I get it to record EVERYONE's name? BTW: THANKS A MILLION for this. I am so new to this whole thing and you make it look so basic.
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Jan 25, 2006 3:19 pm   
 
Hrm why the extra {?

Try chaging {%1} to "%1" in the condition? Added a delitem to %null or blank entries as well.

#ONINPUT "qwtrig" {qw} {~qw;#VAR qw %null;#TEMP {(%d)h, (%d)m, *-} {#STATE qwtrig 0;#VAR qw %replace( %replace( @qw, "||", "|"), " ","");#DELITEM qw %null;#NOOP Process here}} "" {notrig}
#COND {^(*)$} {#VAR QW %concat( @QW, "|", %replace( "%1", ",", "|"))} {looppat|param=999}
Reply with quote
jluce7
Beginner


Joined: 20 Dec 2005
Posts: 22

PostPosted: Wed Jan 25, 2006 3:59 pm   
 
This seemed to only catch the first bit in the variable. (my health and defenses) but stopped as soon as it got to the names. Larkin actually posted something like this on another forum:

#TRIGGER {^(*)$}
VALUE:
#if (%regex( %1, "\d")) {#state qw_capture 0;#var CityEnemies {%subregex( @CityEnemies, "[^\w]+", "|")}} {#var CityEnemies {%concat( @CityEnemies, "%1")};#state qw_capture 1}

Of course this is his for his Cityenemies but I tried it and it seems to catch everyone's name on QW, seperated by commas. I just don't know how to get it to feed the names one at a time into the evaluator I made. The way I picture it working is...pulls first name, evaluates it, pulls necessary info, discards name, moves to next name and repeats. But I don't know how to make this work. Again, my apologies for my inexperience and a million thanks for all the help.
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Jan 25, 2006 4:42 pm   
 
You'll want to convert Cityenemies into a string list then:
#VAR Cityenemies {Tom,Dick,Harry}
#VAR Cityenemies %replace(@Cityenemies,",","|")
#VAR Cityenemies {Tom|Dick|Harry}

Then we can use the #FORALL and go through the string list and do your evaluate to it.
#FORALL @Cityenemies {evaluate %i}
Reply with quote
jluce7
Beginner


Joined: 20 Dec 2005
Posts: 22

PostPosted: Wed Jan 25, 2006 9:45 pm   
 
Ok so.. I got it to list as a string which is cool..Thanks a bunch.

I am having trouble with the FORALL tho. I have a seperate class we can call HonoursChecker that once the honours is displayed pulls the necessary info out and then runs an alias as a tester to see if certain info is true. If it is, It's assigned to another string I will be displaying.

So far I have the regex example up there, with it converting it to the string list, then I have a whole seperate class to do the evaluation of the honours I see. I tried #FORALL @BW {honours %i} and it didn't seem to work. (this was just so I would have a visual as to whether it works or not.)


How should the #FORALL be written?
#FORALL @BW {#t+ honourschecker;honours %i;checkeralias;checkerreset alias}? ???

Basically I have alot of gagging goin on in the honourschecker class so I don't want it active ALL the time. Or should I just combine the two classes to work as one? Also, how do I reset the @QW string when I am done?


Also I noticed just now that sometimes the QW list starts with this a , (comma/space) carried over from the line before. This seems to mess it up a little.
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Jan 25, 2006 10:02 pm   
 
#VAR Cityenemies {Tom,Dick,Harry}
#VAR Cityenemies %replace(@Cityenemies,",","|")
#DELITEM Cityenemies %null
#VAR Cityenemies {Tom|Dick|Harry}

Using that DELITEM to get rid of blank entries will help some.

If you have huge overhead scripts being done then expect to get hit with huge lag. I'd do something like (if I understand your checker aliases properly:
#t+ honourschecker
#FORALL @BW {#PRI{honours %i}}
checkeralias
checkerreset alias
#T- honourschecker

Unless that is seriously hard on the processor then I would make a trigger to toggle off the end of the check to start the next one.
ie
#ALIAS honcheck {#IF (!%null(@QW) {honours %pop(QW);#TEMP honcheckcontinue {^Some end message trigger from the honors check} {#ALARM honcheckalarm +0.5 {honcheck}}} {#ECHO Done Honours checking}}
Reply with quote
jluce7
Beginner


Joined: 20 Dec 2005
Posts: 22

PostPosted: Thu Jan 26, 2006 1:20 am   
 
Ok, this is basically what I have. I use their honours to pull info. One bit is to see if they are infamous. So here is the infamy checking script I have so far......
Alias/Variable names are just so you get a better idea of what they do.


#CLASS {bwcapturer} {disable}
#TRIGGER {^(*)$} {#if (%regex( %1, "\d")) {#state bw_capture 0;#var BW {%subregex( @BW, "[^\w]+", "|")}} {#VAR BW %replace(@BW,",","|");#var BW {%concat( @BW, "%1")};#state bw_capture 1}}
#CLASS 0

#CLASS {BWTESTER} {disable}
#VAR infamousplayers
#VAR solidinfamous
#VAR invetinfamous
#VAR entrenchedinfamous
#VAR staggerinfamous
#VAR permainfamous
#ALIAS infamyreset {infamy=0}
#ALIAS infamychecker {#IF @infamy=0 {#NOOP};#IF @infamy="1" {#ADDITEM infamousplayers %i};#IF @infamy="2" {#ADDITEM solidinfamous %i};#IF @infamy="3" {#ADDITEM invetinfamous %i};#IF infamy="4" {#ADDITEM entrenchedinfamous %i};#IF @infamy="5" {#ADDITEM staggerinfamous %i};#IF @infamy="6" {#ADDITEM permainfamous %i}}
#ALIAS iwho {#SH {"[Infamous:]" @infamousplayers};#SH {"[Solidly Infamous:]" @solidinfamous};#SH {"[Inveterately Infamous:]" @invetinfamous};#SH {"[Entrenched Infamous:]" @entrenchedinfamous};#SH {"[Staggeringly Infamous:]" @staggerinfamous};#SH {"[Near-Permanent Infamous:]" @permainfamous}}
#TRIGGER {^{She|He} is one of the Infamous.$} {#GAG;infamy=1}
#TRIGGER {^{She|He} is one of the solidly Infamous.$} {#GAG;infamy=2}
#TRIGGER {^{She|He} is one of the inveterately Infamous.$} {#GAG;infamy=3}
#TRIGGER {^{She|He} is one of the entrenched Infamous.$} {#GAG;infamy=4}
#TRIGGER {^{She|He} is one of the staggeringly Infamous.$} {#GAG;infamy=5}
#TRIGGER {^{She|He} is one of the near-permanent Infamous.$} {#GAG;infamy=6}
#TRIGGER {^{She|He} is {a|an} * in *.$} {#GAG}
#TRIGGER {^{She|He} is * years old, *} {#GAG}
#TRIGGER {^*fall of the Seleucarian Empire.$} {#GAG}
#TRIGGER {^{She|He} is ranked * in Achaea.$} {#GAG}
#TRIGGER {^{She|He} is unranked in Achaea.$} {#GAG}
#TRIGGER {^{She|He} is the * ranked *.$} {#GAG}
#TRIGGER {^{She|He} is * character.$} {#GAG}
#TRIGGER {^{She|He} is not known for acts of infamy.$} {#GAG;infamy=0}
#TRIGGER {^{She|He} is a member of the Quisalis Mark.$} {#GAG}
#TRIGGER {^{She|He} is a member of the Ivory Mark.$} {#GAG}
#TRIGGER {^{She|He} is a proud soldier of *.$} {#GAG}
#TRIGGER {^{She|He} is considered to be approximately * of your might.$} {#GAG}
#TRIGGER {^{Her|His} motto: *$} {#GAG}
#TRIGGER {^{His|Her} warcry: *$} {#GAG}
#TRIGGER {^{He|She} bears the arms: *} {}
#COND {*.$} {#GAG} {within|param=1}
#TRIGGER {^{He|She} has filed issues against others *.} {#GAG}
#TRIGGER {^{She|He} has triumphed *.$} {#GAG}
#TRIGGER {^{He|She} is a proud soldier of *.$} {#GAG}
#TRIGGER {^{He|She} walks with Divine Grace.$} {#gag}
#TRIGGER {^{She|He} is a member of the *.$} {#GAG}
#TRIGGER {^* {Female|Male} *.$} {#GAG}
#CLASS 0

I also have an alias "InfamyLister" that does the FORALL:
#t+ bwtester
#FORALL @BW {honoursb %i;infamychecker;infamyreset;#wait 1000}
#t- bwtester

Basically, I want it to honours the person (from the @BW string) which so far it does. But then I want it to see what level of infamy they are and assign it to a new string, which then I can show when I type IWHO.

The problem is, this seems to work except for the IWHO, which now shows EVERYONE I just honours'd. (HONOURSB in Achaea gives you a BRIEF honours so I didn't have to gag so much). Before I had it working, and now for some reason it doesn't. It puts all kinds of people in there whether or not they are infamous.
Reply with quote
jluce7
Beginner


Joined: 20 Dec 2005
Posts: 22

PostPosted: Fri Jan 27, 2006 5:52 am   
 
Ok, messed with it a little more. Put in something like:

#ONINPUT honoursb %1 {%1=person}

then made it so it #ADDITEM <infamouslevel> @person if they are infamous.

This seems to put people in, but not infamous people, and not in the right category.

ANY help past what you've already graciously helped me with would be VERY appreciated. Thanks
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Fri Jan 27, 2006 6:05 am   
 
I'd throw your idea in #ALIAS infamychecker into the last trigger line you can capture when you do the honors check on them. By calling that alias like that, gosh nows how it time slices with all the running loops.

You should use #IF syntax like:

#IF ((condition1) AND (condition2)) {true condition} {false condition}

Put them () around stuff so it processes it always ok.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Fri Jan 27, 2006 8:13 pm   
 
There was a large thread about all this on the Achaea Forums, and we took care of most of these issues, especially the capturing of names. (I posted my method for capturing them off a city enemies list, which can easily be adapted to capture QW/BW output.)

Don't use #WAIT, especially when looping several hundred times and pausing for a second each time. You're royally hosing your client that way.

Your command input syntax is quite wrong, and doesn't really seem to be doing what you want it to, I think. This one will at least capture the name of the person whose honors you're checking, and then you can use @person to add them to your list of infamous people when that trigger line fires.

Code:
#ONINPUT {^\s*honou?rsb?\s+(\w+)\s*$} {person = %1} "" {regex}


I'll be happy when the coders (i.e., admins) finally get around to just making an InfamyWho command, so we don't have to hash over this same script time and time again. Rolling Eyes
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