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
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Fri Feb 23, 2007 7:10 am   

prompt editing
 
The command prompt could look something like this:
1420h, 1420m abcdetp(-) <mud text>
Ive been searching for a way to check for one specific character such as e or a lack thereof. None of the wild cards seem to work. Is there an easy way to do this? Also there could be an "h" in the string as well as the "h" after the 1420. Could this cause confusion?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Feb 23, 2007 1:00 pm   
 
You can do it with regex - the question mark makes the previous character or operator optional. In zScript triggers the easiest way is to use (%w) to capture the whole string and then use %pos to determine whether or not the string contains that letter.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Feb 23, 2007 2:10 pm   
 
Looks like you are trying to make a health gauge or more likely an auto health sipper.

The following is NOT using regex. I have done it both ways but seeing that you weren't sure how to do this Zmud's own pattern matching is more newbie friendly.

%d as you probably know by now matches numbers. And you want to know if your health is low so we need to capture it.

Trigger pattern:
^(%d)h, %dm %x
Trigger script:
#say My health is %1

The ^ carrot symbol is making sure that it starts at the beginning of a line. The %x doesn't care if it is a word or number or punctuation mark. Only that it doesn't contain any spaces.

For mana you could use.

^%dh, (%d)m %x
#say My mana is %1

Here is an example using #IF, checking for e.

^%dh, %dm (%x)
#IF (%pos( "e", %1) != 0) {#say Yep you have equilibrium.}

Now you are wanting to combine this information so.

^(%d)h, (%d)m (%x)
#say My health is %1
#say My mana is %2
#IF (%pos( "e", %3) != 0) {#say Yep you have equilibrium.} {#say No equilibrium here.}

Enjoy.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
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