Prompt Help please

Posted by Deladan on Thu 23 Sep 2010 03:55 PM — 7 posts, 33,087 views.

#0
Ok here goes, I'm trying to use my prompt to grab variables from, such as balance and equilibrium.

Currently my prompt is


8360h, 5944m, 33900e, 29394w, 27% cexkdb|0/0|0/0|0/0|99-

My prompt trigger is

^(?pval.health:\d+)h, (?pval.mana:\d+)m, (?pval.endurance:\d+)e, (?pval.willpower:\d+)w,


It matches at this point but every time I try to expand it to match everything I need it to match it messes up. Also I'm trying to grab the varibable based off the position of e and x in that prompt

I know that in zmud the coding for grabbing something like that is #if (%pos;x,%5)) {#var balance 1} {#var balance 0};#if (%pos(e,%5)) {#var equib 1} {#var equib 0}

Netherlands #1
Try this trigger (I removed the named captures from your base sample since they detract from the regular expression, but feel free to add them back in if you want them):

^(\d+)h, (\d+)m, (\d+)e, (\d+)w, ([cexkdb]+)|(\d+)/(\d+)|(\d+)/(\d+)|(\d+)/(\d+)|(\d+)-


Numeric captures are as follows:

1 = health
2 = mana
3 = endurance
4 = willpower
5 = status indicators, assumes at least one letter present.
6 till 11 = big bunch of zeroes
12 -> number 99 in your example


In simple Send to: triggers, you can use the syntax %1-%8, as I believe number 0 as well as 9 and above get some special values in them, but it doesn't seem to matter for your problem. (Using a script function would free up all numbers though, as would the function GetTriggerWildcard.)

Now, as for your checks of a letter being present in that string of yours, try using string.find (assuming Lua):

if (string.find("%5", "c")) then
  Note("Woo, found myself a letter c.")
else if (string.find("%5", "x")) then
  Note("Woo, found myself a letter x.")
else
  Note("This sucks, I found nothing I could use.")
end
USA #2
^(?pval.health:\d+)h\, (?pval.mana:\d+)m\, (?pval.endurance:\d+)e\, (?pval.willpower:\d+)w\, \d+\% ([c]?[e]?[x]?[k]?[d]?[b]?[@]?)\|(\d+)\/(\d+)\|(\d+)\/(\d+)\|(\d+)\/(\d+)\|(\d+)\-$

if c == "c" then Note("I has cloak") end
if e == "e" then Note("I has eq") end

etc, etc. Gah, forumcodes messing with the code. Fixed.
Amended on Thu 23 Sep 2010 05:11 PM by Dontarion
Netherlands #3
Try clicking the Check this if your message uses 'forum codes' or templates (auto-detected for new posts) checkbox below the part where you type your post. :) (Edit: Oh wait, the problem was with your regex being changed. Could have escaped the [ and ] thingies using backslashes \ - it's one of the twitchier sides of this otherwise lovely forum.)

Also, read my post again. It should have a pretty much fully working example. Pay close attention to how I check for the presence of the letters, and how I trigger on them.
Amended on Thu 23 Sep 2010 05:10 PM by Worstje
USA #4

^(\d+)h, (\d+)m, (\d+)e, (\d+)w, (\d)\% ([cexkdb]+)|(\d+)/(\d+)|(\d+)/(\d+)|(\d+)/(\d+)|(\d+)-


Wostje left out the 27% capture in his otherwise spot-on reply... Change %5 to %6 in his sample code...
Australia Forum Administrator #5
Worstje said:

In simple Send to: triggers, you can use the syntax %1-%8, as I believe number 0 as well as 9 and above get some special values in them, but it doesn't seem to matter for your problem. (Using a script function would free up all numbers though, as would the function GetTriggerWildcard.)


Wildcards %1 through to %9 work as you would expect (1st to 9th captured expression). For 10 onwards use %<10>, %<11> etc.

Or for named wildcards: %<health>, %<mana> etc.
Netherlands #6
Wonderful, another thing learned.

Shows you how often I use the send-to functionality. =)

@WillFa: Nice catch. I missed that one.