|
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: 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? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: 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 |
|
|
|
|
|