|
Phonox Newbie
Joined: 20 Feb 2008 Posts: 4
|
Posted: Wed Feb 20, 2008 1:50 pm
about Special Characters |
i need some help with (), /, [], {}, \ in muds..
what do i write to skip that part?
i've written a working trigger to make my character to run and buy senzu beans by this trigger if the () wasn't there..
Pattern:
(%d) a senzu bean
Value:
#PRI {#IF (%1<11) {MATT}}
MATT is just a alias for the running part..
if i change %d to %1 it would end up to trigger everytime i see a senzu bean.
and if i remove the () then it will never trigger just as for the moment.. |
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Wed Feb 20, 2008 3:19 pm |
to escape special charaters in ZMud patterns you can use a tilde ~
I am not sure what you mean by this " () wasn't there"
if you need those in the pattern match ~((%d)~) should work
you must really like senzu beans |
|
|
|
Phonox Newbie
Joined: 20 Feb 2008 Posts: 4
|
Posted: Fri Feb 22, 2008 10:07 pm |
Great it works!!! but when it's less then 10 it becomes a 'space' instead of the first number..
( 2) a senzu.....
(22) a senzue....
then it won't work.. =/ is it possible to remove that space to? or do i have to make a new trigger for that one?
and while im at it.. how do i connect one room with a portal to another zone?? =S tried to look up that but i failed |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Fri Feb 22, 2008 10:33 pm |
To catch the optional leading space, change the trigger type to a regular expression (regex) trigger and use a pattern like
Code: |
\(\s?(\d+)\) a senzu bean |
or
Code: |
\(((?:\s\d)|(?:\d+))\) a senzu bean |
|
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
Phonox Newbie
Joined: 20 Feb 2008 Posts: 4
|
Posted: Thu Mar 13, 2008 6:33 pm |
what should i write to make % to dissapair?
as in this..
Code: |
[ 91 Snt] kralels 100% hp 94% mana 95% mv 364109 xp |
i want to have it like this in my trigger..
Code: |
%* Nathral %1%~% hp%* |
but in that case i get %1 as 100%.. and i can't get it to work with that % at the end..
#If (%d>80%) {c heal kralels} {c ray}
(i've tried tried with and without the % in that IF-sentance)
then it will only use the 'fail-situation' as is in this case 'c ray'
or always true.. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Mar 13, 2008 6:44 pm |
Okay, you're doing a number of things wrong. The first is that your pattern doesn't match the text - I'm not sure why you're using %* here when it's practically never needed, and your construct %1% doesn't make sense. Your pattern also contains the word "Nathrals", which isn't present in the text. See the topic on pattern matching for more info on how to write patterns. A real pattern to match that text would look something like this:
~[ %d %w~] (%w) (%d)~% hp (%d)~% mana (%d)~% mv (%d) xp
Each item in brackets (and only those in brackets) is made available to scripts, numbered %1-%99 depending on where the brackets opened. So %1 will be "kralels", %2 will be 100, %3 will be 94, %4 will be 95 and %5 will be 364109. So now, in the script of the trigger you can do:
#if (%2>80) {c heal %1} {c ray}
or whatever you want to do. |
|
|
|
Phonox Newbie
Joined: 20 Feb 2008 Posts: 4
|
Posted: Thu Mar 13, 2008 6:54 pm |
it looks perfect.. even thought i never thought that i would need that much... but the 'pattern doesn't match' it still sais.. =/
even if i changed the first %2 to a %4 instead because i guess the 2 would be the %w in the begining.. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Mar 13, 2008 6:59 pm |
It's because of the spaces. You need to use the [code] tag to preserve spaces when you paste things into the forums. I've added them to your post.
To match more than one (or a variable amount of) space, use %s, so:
~[%s%d%s%w~] (%w)%s(%d)~% hp%s(%d)~% mana%s(%d)~% mv%s(%d) xp
As I said in my previous post, you should almost certainly be using %2 in your script. %2 is the contents of the second set of brackets in the pattern - in this case, the hp percentage. |
|
|
|
|
|