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
➜ Filter out nonsense in Room descriptions
Filter out nonsense in Room descriptions
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Norbert
USA (61 posts) Bio
|
Date
| Sun 25 Jan 2004 08:12 AM (UTC) |
Message
| I'm trying to make a script that will take out the majority of the articles and prepositions in a room description leaving only nouns and verbs in order to create a list of things that can be looked at in a room. It works fine, I was just wondering if anyone knew a better way to do it. The script i have is rather lengthy.
first I copy the room description into the variable 'room'
<aliases>
<alias
script="examine_array"
match="examine"
enabled="y"
sequence="100"
>
</alias>
</aliases>
sub examine_array(name, output, wilds)
dim items, i, rest
rest = ""
items = split(world.GetVariable("room"))
for i = 1 to Ubound(items)
select case items(i)
case "a"
case "the"
case "an"
case "you"
case "is"
case "if"
case "was"
case "be"
case "To"
case "see"
case "and"
case "there"
case "There"
case "You"
case "A"
case "The"
case "are"
case "with"
case "within"
case "without"
case "where"
case "come"
case "that"
case "read"
case "learn"
case else rest = rest + " " + items(i)
end select
next
world.note rest
end sub
my actual script has almost 100 words it looks for
|
Norbert
-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 25 Jan 2004 07:47 PM (UTC) |
Message
| This might be quicker and easier to maintain.
I used a regular expression to replace the words in your room description by a space, and then used the MUSHclient "replace all" to replace multiple spaces with one space (in case two came in a row).
For ease of maintenance you could keep the target words in a variable themselves.
eg.
regEx.Pattern = "\\b(" & GetVariable ("words") & ")\\b"
The "\\b" is used to mark a "word boundary" (like space, comma, period etc.) so it doesn't strip the "a" out of the middle of words.
Here is the alias:
<aliases>
<alias
match="examine"
enabled="y"
send_to="12"
sequence="100"
>
<send>Set regEx = New RegExp
regEx.Pattern = "\\b(a|the|an|you|is|if|was|be|to|see|and|the)\\b"
regEx.IgnoreCase = True
regEx.Global = True
result = regEx.Replace(GetVariable ("room"), " ")
Set regEx = nothing
world.note world.Replace (result, " ", " ", vbTrue)</send>
</alias>
</aliases>
Example of use:
Original description
You stand inside the Darkhaven Academy, an establishment designed to teach the basics of play inside this game. Each room has a specific purpose and contains information on the various commands to maneuver around and interact with the players. We recommend you explore the Academy in full, taking the time to read the instructions in each room.
After applying "examine"
stand inside Darkhaven Academy, establishment designed teach basics of play inside this game. Each room has specific purpose contains information on various commands maneuver around interact with players. We recommend explore Academy in full, taking time read instructions in each room.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Norbert
USA (61 posts) Bio
|
Date
| Reply #2 on Sun 25 Jan 2004 08:33 PM (UTC) |
Message
| Thank you very much! I put my word list into a variable as you suggested and it works great, thanks again. |
Norbert
-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
| 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.
12,367 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top