Register forum user name Search FAQ

Gammon Forum

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 ➜ mushclient, com objects and hooks

mushclient, com objects and hooks

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Tspivey   Canada  (54 posts)  Bio
Date Sun 30 Oct 2005 02:10 AM (UTC)
Message
Hello. I need to do the following:
1. create a com object, and keep it until mushclient exits.
2. on every line received (including world.note), send it to that com object.
this would exclude gags, etc.
is this possible?
I know how to create a com object with CreateObject, but not sure how to keep it there.
I"m also not sure how to hook into world.note.
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #1 on Sun 30 Oct 2005 03:05 AM (UTC)
Message
This is pretty simple. In both plugins and the main script file, any variable declaired 'outside' of a function is kept, so long as the script doesn't reload or the program exits.

For example, if this was your script:

dim a
dim d

sub Create_Objects (name, output, wilds)
  a = createobject("My_Object")
  b = createobject("My_Object")
  c = createobject("My_Object")
  dim d
  d = createobject("My_Object")
end sub

dim c

sub Do_Somestuff (...)
end sub


Both a and c will remain for as long as the script is not reloaded and/or you exit mushclient. b however will be lost as soon as Create_Objects returns control to mushclient, since its 'local' to Create_Objects, while the others are 'global'. 'd' is lost because you create a 'new' d, which is specifically declared 'local' by the 'dim' in that sub. (Or it should). Since b doesn't exist in the 'global' layer, its automatically assumed to be 'local' and thus vanishes, like d in this case, because it was created in the sub.

Note. All variables created using 'send to script' in triggers, aliases and timers exist in the 'global' space. This means they can overwrite values you intended to make permanent, unlike those created and destroyed in a sub, if you accidentally use the same name. This is why a, b, c, d are probably 'bad' names, while 'mywindow' or the like will prevent accidentally messing up. ;) Hope that helps.
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 30 Oct 2005 03:52 AM (UTC)
Message
This is to do with the screen reader isn't it?

I have been thinking that there isn't really an easy way to capture every line that is typed in, displayed with world.note, and sent from the MUD.

Thus I have added an extra plugin callback into version 3.68 - OnPluginScreendraw.

This hooks into the "display line" routine, in such a way that it will capture input lines (things you type), note lines (from scripts) and also output lines that have not been gagged. This should work around your problem that your screen reader currently reads the lines that appear, even if they are about to be gagged.

A small plugin, like the one below, illustrates its use.

As for the COM side of it, as Shadowfyr suggests, you simply need to open the COM object (with CreateObject) early on, and store it in a variable outside any function.

You might create the COM object in OnPluginInstall.

The arguments to OnPluginScreendraw are:

type: type of line, where 0 = output line, 1 = note, 2 = command

log: are we planning to log it?

line: the text of the line itself


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, October 30, 2005, 3:29 PM -->
<!-- MuClient version 3.68 -->

<!-- Plugin "screendraw_test" generated by Plugin Wizard -->

<muclient>
<plugin
   name="screendraw_test"
   author="Nick Gammon"
   id="9afd5521a287f53094d238ea"
   language="Lua"
   purpose="testing OnPluginScreendraw"
   date_written="2005-10-30 15:27:42"
   requires="3.68"
   version="1.0"
   >

</plugin>


<!--  Script  -->


<script>
<![CDATA[
function OnPluginScreendraw (type, log, line)
  AppendToNotepad ("test", type, " ", log, " ", line, "\r\n")
end -- function
]]>
</script>


</muclient>


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Tspivey   Canada  (54 posts)  Bio
Date Reply #3 on Thu 03 Nov 2005 11:50 PM (UTC)
Message
When will 3.68 be released, so I can try this feature and get some scripts going for it?
I think that this is the answer to some, if not most,
of my problems - calling the screen reader through its api is sometimes
better than letting a screen reader scrape the screen and not get the results it needs.
Thanks,
Tyler
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #4 on Fri 04 Nov 2005 08:51 PM (UTC)
Message
In the next couple of days.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #5 on Sun 06 Nov 2005 02:52 AM (UTC)
Message
Version 3.68 is released now, see:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6055

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #6 on Sat 27 May 2006 11:02 PM (UTC)
Message
Also see this thread, which is about using the SAPI (speech API) to speak stuff easily:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6593


- 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.


26,044 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.