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


Joined: 09 Aug 2002
Posts: 3

PostPosted: Fri Aug 09, 2002 8:44 pm   

Multiple instances
 
Hey all,

I'm kinda new to this, so probably this has been answered already..

How would you set zMUD up to trigger multiple instances on one line

Lets say that my trigger should add one to var blah everytime blah shows up

So

Blah dfds Blah dfdsfs Blah fdsfs Blah

Should give a value of 4, but I can't figure out how to do this

Thanks :)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Aug 09, 2002 11:05 pm   
 
#TR {blah} {#VAR TempCounter %trigger;#WHILE (%pos("blah",@TempCounter) {#ADD blah 1;TempCounter=%remove("blah",@TempCounter)}}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Aug 09, 2002 11:55 pm   
 
Why would anyone bother counting "blah"'s? Just move to a more interesting MUD!
Is there any good reason to conceal what you actually want to count?

Anyway, something like this should do it.

#TR {blah} {#MATH blah {%if(%begins({%trigger},"blah"),1,0) + %if(%ends({%trigger),"blah"),1,0) + %numwords({%trigger},"blah") - 1}

LightBulb
Senior Member
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Aug 10, 2002 12:13 am   
 
I like Lightbulb's better, of course he has a few typos and I can shorten it a little.
#TR {blah} {#MATH blah {%begins({%trigger},"blah") + %ends({%trigger},"blah") + %numwords({%trigger},"blah") - 1}}

The is no accounting for taste, blah that is bad.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Aug 10, 2002 3:33 pm   
 
Typos? I don't see any. But you're right, %if isn't needed. Nice.
AHA! I did find one

LightBulb
Senior Member
Reply with quote
Saffire
Newbie


Joined: 09 Aug 2002
Posts: 3

PostPosted: Mon Aug 12, 2002 4:01 pm   
 
Err, I was just too lazy to type it out at first

What I really want to do is to execute a command whenever a certain pattern comes up

So basically the pattern would be :

Name1.......[213]

No given amount of periods, and this could happen multiple times on a line

Name1....[121] Name2...[1] Name3...[34]

Lets say I want to 'whois %1' everytime I see this, how would I go about doing this?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Aug 12, 2002 10:28 pm   
 
quote:

Err, I was just too lazy to type it out at first

What I really want to do is to execute a command whenever a certain pattern comes up

So basically the pattern would be :

Name1.......[213]

No given amount of periods, and this could happen multiple times on a line

Name1....[121] Name2...[1] Name3...[34]

Lets say I want to 'whois %1' everytime I see this, how would I go about doing this?





#trigger {Name1[.]~[%d~]} {}

li'l shmoe of Dragon's Gate MUD
Reply with quote
Saffire
Newbie


Joined: 09 Aug 2002
Posts: 3

PostPosted: Tue Aug 13, 2002 6:20 pm   
 
Err, ok, I want the pattern to be (%w)[.]~[%d~], but it still only gets one instance, rather then however many I have on the same line.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Aug 13, 2002 7:04 pm   
 
Grab the whole line and convert it to a stringlist using the space as a delimiter. Then, on each one, grab the name by using the period as a delimiter:
#TRIGGER {(*)} {#FORALL %replace("%1", " ", "|") {whois %word(%i, 1, ".")}} "" {notrig}

You need, however, to enable this trigger only when it is necessary and disable it when it is not. You would not want this trigger firing on every word that your MUD sends.

Remember, there are many different way to approach and solve a particular problem, unless specifics about the problem are given, a general solution may be provided which doesn't quite fit what you need.

Kjata
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