Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Prompt Help please

Prompt Help please

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Deladan   (40 posts)  Bio
Date Thu 23 Sep 2010 03:55 PM (UTC)
Message
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}

Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #1 on Thu 23 Sep 2010 04:58 PM (UTC)
Message
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
Top

Posted by Dontarion   USA  (62 posts)  Bio
Date Reply #2 on Thu 23 Sep 2010 05:02 PM (UTC)

Amended on Thu 23 Sep 2010 05:11 PM (UTC) by Dontarion

Message
^(?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.
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #3 on Thu 23 Sep 2010 05:08 PM (UTC)

Amended on Thu 23 Sep 2010 05:10 PM (UTC) by Worstje

Message
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.
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #4 on Thu 23 Sep 2010 08:37 PM (UTC)
Message

^(\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...
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 23 Sep 2010 09:23 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #6 on Thu 23 Sep 2010 11:42 PM (UTC)

Amended on Thu 23 Sep 2010 11:44 PM (UTC) by Worstje

Message
Wonderful, another thing learned.

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

@WillFa: Nice catch. I missed that one.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


24,004 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.