[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Plugin for checking brackets , etc, in MUSH code?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Plugin for checking brackets , etc, in MUSH code?

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Linda   Sweden  (164 posts)  [Biography] bio
Date Thu 15 Jul 2004 12:20 AM (UTC)  quote  ]
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. :)
[Go to top] top

Posted by Nick Gammon   Australia  (19,616 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 15 Jul 2004 03:35 AM (UTC)  quote  ]

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
[Go to top] top

Posted by Linda   Sweden  (164 posts)  [Biography] bio
Date Reply #2 on Thu 15 Jul 2004 09:32 AM (UTC)  quote  ]
Message
Thank you, works like a charm. :) If I manage to make some useful modifications, I'll make sure to post them.
[Go to top] 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.


3,278 views.

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]