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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Stuck in it badly

Stuck in it badly

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


Posted by Nickpick   (24 posts)  [Biography] bio
Date Sat 08 Apr 2006 06:37 PM (UTC)
Message
I've got a problem! Again!

I've got this piece of script, which works in the IMMEDIATE mode, but refuses to work while put into a trigger:

///

set re = new regexp

stringe = "You remove 1 goldenseal root, bringing the total in the Rift to 38."

With re
.Pattern = "^(You remove) (\d|\d\d|\d\d\d|\d\d\d\d) (goldenseal root, bringing the total in the Rift to) (\d|\d\d|\d\d\d|\d\d\d\d)(.)$"
.IgnoreCase = False
.Global = False
End With

ma = re.test(stringe)

world.note ma

world.enabletrigger "GoldensealOUTR", "true"

///
Basically it's supposed to give out -1 and it does, in immediate mode. However, once I insert it into a trigger and make it fire, it gives out 0. Help?
[Go to top] top

Posted by Nickpick   (24 posts)  [Biography] bio
Date Reply #1 on Sat 08 Apr 2006 07:18 PM (UTC)
Message
Issue solved. Incredibly bizarre nevertheless.

///

set re = new regexp

stringe = "%1"

With re
.Pattern = "^(You remove) ([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]) (goldenseal root, bringing the total in the Rift to) ([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9])(.)$"
.IgnoreCase = False
.Global = False
End With

ma = re.test(stringe)

world.note ma

world.enabletrigger "GoldensealOUTR", "true"

///

Just had to replace \d with [0-9]. Funnily enough \d still worked in the IMMEDIATE. Oh well..
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sun 09 Apr 2006 04:14 AM (UTC)
Message
I think in the trigger window, MUSHclient processes sequences like \n to be newlines, so your solution would have been to make \d into \\d in that case.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 13 Jun 2006 09:31 PM (UTC)
Message

(\d|\d\d|\d\d\d|\d\d\d\d)

...

([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9])


Both of these can be simplified by using the "count" syntax:



(\d{1,4})

...

([0-9]{1,4})

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by NeoFryBoy   USA  (42 posts)  [Biography] bio
Date Reply #4 on Tue 04 Jul 2006 08:50 AM (UTC)
Message
Would...

^(You remove) (\d+) (goldenseal root, bringing the total in the Rift to) (\d+)\.$

...be just as fast?
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Tue 04 Jul 2006 09:42 PM (UTC)
Message
They would both be fast enough, the original one matches on 1-4 digits, yours would match on 1 to any number. Unless there was some obscure problem with mismatches (eg. with a 5 digit number) your solution is probably more elegant.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


17,079 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 HostDash]