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
➜ General
➜ Trigger to match variable lengths?
|
Trigger to match variable lengths?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Sleeve
(31 posts) Bio
|
| Date
| Sun 16 Jun 2002 06:54 PM (UTC) |
| Message
| Hello all, I am having a bit of trouble matching a trigger to a variable length. The trigger needs to match something like:
Your quest is to find * and deliver the punishment
But the problem is that depending on the mobile's name, the * can be 1 word to 7 words. Sometimes it can be something like "a troll" or sometimes it can be "a big, scary green troll". So far, I have only had success on matching if the mobile's name is only 1 word. Does that mean that I have to add 7 different triggers to match for varying lengths? Like:
Your quest is to find * and deliver the punishment
Your quest is to find * * and deliver the punishment
Your quest is to find * * * and deliver the punishment
etc.
Any help would be greatly appreciated. Thanks. :) | | Top |
|
| Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
| Date
| Reply #1 on Sun 16 Jun 2002 08:28 PM (UTC) Amended on Sun 16 Jun 2002 08:29 PM (UTC) by Shadowfyr
|
| Message
| Hmm. No it means using a script. Something like this should work:
sub getname(trigname, output, wildcards)
dim mob, temp
temp = split(wildcards(1)," ") 'Turns the words into an array.
mob = temp(ubound(temp)) 'Retrieves the "last" word in the array (assumed to be the monsters name).
... 'Use world.setvariable to store the name for later or a world.send to execute a command. You where a bit unclear about what you intended here. ;)
end sub
As long as the last word is 'always' the monster you should be OK. If they starts sending you stuff like 'a horrible troll - wearing a green coat' you would have to do something a 'lot' more complicated. | | Top |
|
| Posted by
| Sleeve
(31 posts) Bio
|
| Date
| Reply #2 on Sun 16 Jun 2002 08:56 PM (UTC) |
| Message
| Well, not only is the mob's name sometimes not the last word, but there are times where I'm not going to be able to use only 1 word for the mob's name.
Example, I am using this for an auto-tracking of the mob. If I have a quest to seek out a "large cat" instead of a "grey cat", I can't attempt to simply "track cat" since it could lead me to the wrong one. I need to be able to "track 'large cat'". That's why I was hoping to be able to use the mob's name as a whole, not just the last word.
Thanks for the help though. I'll keep trying. :) | | Top |
|
| Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
| Date
| Reply #3 on Sun 16 Jun 2002 09:43 PM (UTC) Amended on Sun 16 Jun 2002 09:48 PM (UTC) by Shadowfyr
|
| Message
| Hmm. Ack!!
Well... Then:
sub getname(trigname, output, wildcards)
dim test, test2, test3, mods, mobs
mods = "large,small,grey,black"
mobs = "cat,troll,dog"
for each test in split(mods,",")
for each test2 in split(mobs,",")
test3 = test & " " & test2
if InStr(wildcards(1),test3) then
... 'Do whatever (using test3).
exit sub
endif
next
next
end sub
The only drawback is that you need to provide all the possible modifiers and monster types, but this is 'probably' the only certain way of having it work. It may be possible to shorten it a bit by combining my previous one, instead of searching every mob type though (assuming again that the modifiers are 'only' in front of the name). ;)
i.e.:
sub getname(trigname, output, wildcards)
dim test, test2, test3, mods
mods = "large,small,grey,black"
for each test in split(mods,",")
if InStr(wildcards(1),test) then
test2 = split(wildcards(1)," ")
test3 = test & " " & test2(ubound(test2))
... 'Do whatever (using test3).
exit sub
endif
next
end sub
| | Top |
|
| Posted by
| Sleeve
(31 posts) Bio
|
| Date
| Reply #4 on Sun 16 Jun 2002 09:54 PM (UTC) |
| Message
| Thanks for taking the time to help me out Shadowfyr, but I don't think this will be to helpful either. :( Then the problem arises where the mob's have names, for example "Mayor Smith" or whatnot, not to mention having multiple modifiers before the mob's name or as you pointed out, modifiers not necessarily preceding the mob's name.
If it's simply easier to add the 7 triggers to check for varying lengths of a mob's name, then by all means I am not averse to doing that. I was just wondering if there was a simpler way than adding 7 triggers, to encompass them all in 1 trigger somehow. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Sun 16 Jun 2002 10:27 PM (UTC) |
| Message
| Are you making this more complicated than it needs to be? If the trigger is:
Your quest is to find * and deliver the punishment
Then that will match any number of words (* is any length text, not just a word).
Thus, if you receive:
Your quest is to find a big, scary green troll and deliver the punishment
Then wildcard 1 will be "a big, scary green troll".
Then by sending:
track %1
It will send:
track a big, scary green troll
Is this what you want, and if not, in what way? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
| Date
| Reply #6 on Sun 16 Jun 2002 10:43 PM (UTC) Amended on Sun 16 Jun 2002 10:44 PM (UTC) by Shadowfyr
|
| Message
| I suspect that some of those modifiers are just modifiers. i.e. the mud he plays expects 'green troll' or possibly 'scary green troll', but not 'a big, scary green troll'. If it did then his first attempt would have worked.
As an anti-botting feature it is definitely effective. | | Top |
|
| Posted by
| Sleeve
(31 posts) Bio
|
| Date
| Reply #7 on Sun 16 Jun 2002 10:47 PM (UTC) |
| Message
| | Thanks Nick, I found the problem, my regular expression had an error in it. I'm so embarassed, sorry about that. :) Thank you both Shadowfyr and Nick. | | 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.
22,400 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top