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
➜ Plugins
➜ Plugin for checking brackets , etc, in MUSH code?
|
Plugin for checking brackets , etc, in MUSH code?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Linda
Sweden (164 posts) Bio
|
| Date
| Thu 15 Jul 2004 12:20 AM (UTC) |
| Message
| Would it be possible to use a plugin as a replacement for a softcoded command that checks a MUSH code attribute and reports back the number of braces, brackets and parenthesis?
Essentiall, you need something where you can do 'check <#dbref>/<attribute>' or 'check <#dbref>/<attributepattern>' and where it puts out something like this:
ATTRIBUTE: { }: 4/4 [ ]: 26/26 ( ): 40/40
If that looks doable, could someone perhaps give me some pointers towards how to construct one? Unless there's one out there already, of course. :) | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Thu 15 Jul 2004 03:35 AM (UTC) Amended on Thu 15 Jul 2004 03:40 AM (UTC) by Nick Gammon
|
| Message
| This should do it Linda. It only does one attribute at a time at present, but it should give you a kickstart for modifying to handle more.
You can copy and paste the code below into a file, or simply download it from the plugins page (name CheckAttribute):
http://www.gammon.com.au/mushclient/plugins/
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, July 15, 2004, 1:30 PM -->
<!-- MuClient version 3.50 -->
<!-- Plugin "CheckAttribute" generated by Plugin Wizard -->
<muclient>
<plugin
name="CheckAttribute"
author="Nick Gammon"
id="a3e213677c69a51c376ba5d8"
language="VBscript"
purpose="Counts brackets in a MUSH attribute"
date_written="2004-07-15 13:23:44"
requires="3.25"
version="1.0"
>
<description trim="y">
<![CDATA[
This counts brackets in a MUSH attribute.
Usage
-----
Type: check dbref/attribute
eg.
check me/name
It will send a request to the MUSH for the attribute, when it replies
a trigger will catch it and count the various bracket types.
For this help, type: CheckAttribute:help
]]>
</description>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="@password *=*"
name="attribute_editor"
omit_from_output="y"
script="count_brackets"
sequence="100"
>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
match="check */*"
enabled="y"
expand_variables="y"
omit_from_output="y"
>
<send>@@pemit/silent me=@password %2=[get(%1/%2)]
</send>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
'
' count number of times one character appears in a string
'
function count_one_thing (txt, what)
dim i
dim count
'
' zero counter
'
count = 0
'
' process whole string
'
for i = 1 to len (txt)
if mid (txt, i, 1) = what then
count = count + 1
end if ' item found
next
'
' return result
'
count_one_thing = count
end function ' count_one_thing
'
' counts number of various types of brackets in an attribute
'
sub count_brackets (thename, theoutput, thewildcards)
dim txt
'
' show the attribute name (wildcard 1) and the contents
' (wildcard 2)
'
Note "Attribute: " & thewildcards (1) & _
" = " & thewildcards (2)
'
' save contents in temporary variable
'
txt = thewildcards (2)
'
' show the counts
'
Note "Attribute: { }: " & _
count_one_thing (txt, "{") & "/" & _
count_one_thing (txt, "}") & " [ ]: " & _
count_one_thing (txt, "[") & "/" & _
count_one_thing (txt, "]") & " ( ): " & _
count_one_thing (txt, "(") & "/" & _
count_one_thing (txt, ")")
end sub ' count_brackets
'
' initialise a unique password to prevent spoofing
'
Sub OnPluginInstall
world.setvariable "password", world.getuniqueid
End Sub
]]>
</script>
<!-- Plugin help -->
<aliases>
<alias
script="OnHelp"
match="CheckAttribute:help"
enabled="y"
>
</alias>
</aliases>
<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
world.Note world.GetPluginInfo (world.GetPluginID, 3)
End Sub
]]>
</script>
</muclient>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Linda
Sweden (164 posts) Bio
|
| Date
| Reply #2 on Thu 15 Jul 2004 09:32 AM (UTC) |
| Message
| | Thank you, works like a charm. :) If I manage to make some useful modifications, I'll make sure to post them. | | 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.
17,402 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top