[MudWalker] Healing Trigger
Kevin Reid
kpreid at mac.com
Thu Jan 29 04:04:58 PST 2009
On Jan 28, 2009, at 20:50, Dom Sengsouvanna wrote:
> My Hp Bar:
>
> Hp: 4185(4185) Gp: 2300(2300) Xp: 3408892 Quest Xp: 0 Socp:
> 168(168)
>
>
> Trigger:
>
> ^ *Hp:(\d+\)(\d+\) +Gp:(\d+\)(\d+\) +Xp:\d+ Quest Xp:\d+\ +Socp:\d+\
> (\d+\) *$
...
> But this doesn't seem to work. Can someone tell me what I may be
> doing wrong?
Your pattern does not match the space before the numbers, and it has
mismatched capturing and literal parentheses.
You want:
^ *Hp: *(\d+)\((\d+)\) +Gp: *(\d+)\((\d+)\) +Xp: *(\d+) +Quest Xp: *(\d
+) +Socp: *(\d+)\((\d+)\) *$
Note that there is a "\(" "\)" for each "(" ")" in the original, and
there is a " *" or " +" for every space in the original.
Now, count the capturing parentheses "(" ")" to determine their numbers:
1 Hp
2 Max Hp (I assume)
3 Gp
4 Max Gp
5 Xp
6 Quest Xp
7 Socp
8 Max Socp
so for this trigger you will want to use arg[1] and arg[3] in the
script to get the Hp and Gp fields.
If you don't care about any of the fields, you can skip the capturing
parentheses around them, too:
^ *Hp: *(\d+)\(\d+\) +Gp: *(\d+)\(\d+\) +Xp: *\d+ +Quest Xp: *\d+
+Socp: *\d+\(\d+\) *$
This pattern will match *only* Hp and Gp and put them in arg[1] and
arg[2]. However, I myself would choose the first pattern I gave which
captures *every* field, so that if you want to add additional actions
to do based on your hp bar you can add to the script without adding
> Script:
>
> @@if tonumber(arg[1]) <= 1500 then
> drink healing poton
> @@iftonumber(arg[2]) <= 500 then
> drink mana potion
> @@end
You have a missing space in the second @@if, and no @@end for the
first one. (These mistakes should be mentioned in the little script
error popup.)
--
Kevin Reid <http://homepage.mac.com/kpreid/>
More information about the MudWalker
mailing list