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
➜ Help! I cannot "return" output window text
|
Help! I cannot "return" output window text
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Tamalak
(7 posts) Bio
|
| Date
| Sun 22 Apr 2001 04:36 PM (UTC) |
| Message
| I cannot for the life of me figure this out. This is what I'm trying to do. At a certain point the game sends me a list of eleven words in a line, like this:
Good Fair Good Good Poor Average Poor Fair Good Good Poor
I am trying to get a script to detect each of these words, convert them into numbers (Good = 5, Average = 3, etc.) and total the numbers (5 + 4 + 5 + 5 + 1 + 3 + 1 + 4 + 5 + 5 + 1 = 39) into a variable. But I cannot get a trigger to fire multiple times without losing the variable in which the total is stored! And I do not see a command for scripts that return strings taken from the output window, so how can I write a script that detects what the words are?? How do I do this? Thanks! | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sun 22 Apr 2001 10:15 PM (UTC) |
| Message
| To do this you need a trigger and have that trigger call a script.
Go into the World Configuration -> Appearance -> Triggers and click on "Add" to create a new trigger.
Fill in the following fields and leave the rest unchanged:
Trigger: ^((Excellent|Good|Fair|Poor|Average) ?)+$
Regular Expression: checked
Label: Assessment
Script: OnAssessment
What this will do is match on any combination of the words Excellent, Good, Fair, Poor, Average (followed by zero or one spaces).
If it gets such a match it then calls the script OnAssessment, which you need to add to the script file (ie. at the end). This example is in VBscript:
sub OnAssessment (strTriggerName, strTriggerLine, arrWildCards)
dim MyArray, i, total
total = 0
MyArray = split (strTriggerLine)
for i = lbound (MyArray) to ubound (MyArray)
Select Case MyArray (i)
case "Excellent" total = total + 5
case "Good" total = total + 4
case "Average" total = total + 3
case "Fair" total = total + 2
case "Poor" total = total + 1
End Select
next
world.Note "Total is " + cstr (total)
world.SetVariable "Total", total
End Sub
What this script does is split the trigger line into individual words (with "split"), and then loop through each one adding in the appropriate amount to the total.
The total is then displayed in the output window, and used to set a variable "Total" which you can then use elsewhere.
|
- 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.
12,679 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top