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.
Entire forum
➜ MUSHclient
➜ VBscript
➜ Im a dumby ;(
Posting of new messages is disabled at present.
Refresh page
Posted by
| BruteofDarklord
(3 posts) Bio
|
Date
| Mon 15 Sep 2003 01:45 AM (UTC) |
Message
| I need something to count how many times I receive these messages:
You slash
and
Your slash missed by a league.
What can I do to keep track of how many times these appear? | Top |
|
Posted by
| Norbert
USA (61 posts) Bio
|
Date
| Reply #1 on Mon 15 Sep 2003 02:19 AM (UTC) |
Message
| The easiest way I know of is to make a trigger, then in the trigger window you can see how many times it matches to the right of the variable box. This would only keep track for the one session, anything else you would need to do a little scripting I think. |
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
| BruteofDarklord
(3 posts) Bio
|
Date
| Reply #2 on Mon 15 Sep 2003 02:36 AM (UTC) |
Message
| Thanks, that helps, but can anyone make a script? | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #3 on Mon 15 Sep 2003 03:31 AM (UTC) |
Message
| This should work:
<trigger
name="slash_hit_1"
enabled="y"
match="You slash."
script="CountHits"
sequence="100"
></trigger>
<trigger
name="slash_miss_1"
enabled="y"
match="Your slash missed by a league."
script="CountHits"
sequence="100"
></trigger>
The script:
'
'These hold the number of landed and missed hits respectively
dim hitsLanded, hitsMissed
hitsLanded = 0
hitsMissed = 0
'
'This is the sub that's called by the triggers above
'
sub CountHits(name, output, wildcs)
dim tempArray
'
'Here you split the trigger's name, using "_" as a delimiter
'The result in our case is an array of "slash", "hit/miss", "1"
'
tempArray = split(name, "_")
'
'Select the contents of the tempArray array at position 1 (starting position of any array is 0)
'
select case tempArray(1)
case "hit"
hitsLanded = hitsLanded + 1
case "miss"
hitsMissed = hitsMissed + 1
end select
end sub
What the trigger actually matches on is unimportant here, the script decides which variable to increment by split'ing the trigger's name into three parts, of which the second should always be either 'hit' or 'miss', and looking at that second part. Therefore, as you add triggers name them according to the template: "slash_hit/miss_#", where # just serves the purpose of keeping the names different and can be anything you want really, and "hit/miss" should be either "hit" or "miss" depending on the trigger's actual meaning.
How you display the results of your processing is up to you, but using the InfoBar would seem to be the most convenient way. You can do that as follows:
Modify the CountHits sub:
sub CountHits(name, output, wildcs)
dim tempArray
tempArray = split(name, "_")
select case tempArray(1)
case "hit"
hitsLanded = hitsLanded + 1
case "miss"
hitsMissed = hitsMissed + 1
end select
'
'Added this line to call another sub which updates the InfoBar
'
UpdateBar
end sub
Add the UpdateBar sub:
sub UpdateBar
dim strn
world.InfoClear
strn = "Hits: " & cstr(hitsLanded) & space(5) & "Misses: " & cstr(hitsMissed)
world.Info strn
end sub
| Top |
|
Posted by
| BruteofDarklord
(3 posts) Bio
|
Date
| Reply #4 on Mon 15 Sep 2003 08:17 PM (UTC) |
Message
| Thanks a ton! But where do I paste all that, word for word? | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #5 on Tue 16 Sep 2003 01:54 PM (UTC) |
Message
| Erm, copy the triggers first and go to Mushclient's File->Import... Uncheck all options except for 'Triggers', click on Clipboard. That will add the triggers to your world file.
Next you'll need to install the script. If you don't have a script file associated with your world already then open a plain text editor and paste the following into it:
option explicit
sub CountHits(name, output, wildcs)
dim tempArray
tempArray = split(name, "_")
select case tempArray(1)
case "hit"
hitsLanded = hitsLanded + 1
case "miss"
hitsMissed = hitsMissed + 1
end select
UpdateBar
end sub
sub UpdateBar
dim strn
world.InfoClear
strn = "Hits: " & cstr(hitsLanded) & space(5) & "Misses: " & cstr(hitsMissed)
world.Info strn
end sub
Save the file as AchaeaScript.vbs (or any other name with .vbs extension) somewhere in your Mushclient directory. Now go open Mushclient again and go to Game->Configure->Scripting (Shift+Ctrl+6). In the new window choose Vbscript as your scripting language, check 'Enable script' and click on the Browse button right below that option. Find your saved script file and open it. Click Ok in the Scripting window. Your script will be compiled and become available.
If you have a script file already then just paste the above script (except for 'option explicit' if you already have it also) into that file and save 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.
16,782 views.
Posting of new messages is disabled at present.
Refresh page
top