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

Gammon Software Solutions forum

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

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

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Stuck in it badly

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Nickpick   (24 posts)  [Biography] bio
Date Sat 08 Apr 2006 06:37 PM (UTC)  quote  ]
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)  quote  ]
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  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sun 09 Apr 2006 04:14 AM (UTC)  quote  ]
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  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 13 Jun 2006 09:31 PM (UTC)  quote  ]
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)  quote  ]
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  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Tue 04 Jul 2006 09:42 PM (UTC)  quote  ]
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.


2,521 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]