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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ VBscript
➜ Stuck in it badly
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nickpick
(24 posts) 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? | Top |
|
Posted by
| Nickpick
(24 posts) 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.. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | Top |
|
Posted by
| NeoFryBoy
USA (42 posts) 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? | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | 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.
18,423 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top