[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Prompt Help please
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Prompt Help please

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


Posted by Deladan   (40 posts)  [Biography] 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}

[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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
[Go to top] top

Posted by Dontarion   USA  (62 posts)  [Biography] 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.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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.
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] 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...
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] 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
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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.
[Go to top] 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.


6,954 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]