Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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
➜ Plugins
➜ Plugin callbacks
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Thu 29 Aug 2002 05:57 AM (UTC) Amended on Thu 25 Jun 2009 09:23 PM (UTC) by Nick Gammon
|
Message
| The following subroutines/functions will be called in your plugin if they are present. The names are hard-coded, and a check is made to see if such names exist when the plugin is installed. As each one starts with the characters "OnPlugin" you should not get clashes with your own routines, provided you avoid using that particular prefix when naming your own subs.
[EDIT] - Information now out of date. Instead, see:
http://www.gammon.com.au/scripts/doc.php?general=plugin_callbacks
- OnPluginInstall
'
' Plugin has been installed
'
sub OnPluginInstall
end sub
- OnPluginClose
'
' Plugin is being removed (closed)
'
sub OnPluginClose
end sub
- OnPluginConnect
'
' This world has been connected (to the MUD)
'
sub OnPluginConnect
end sub
- OnPluginDisconnect
'
' This world has been disconnected (from the MUD)
'
sub OnPluginDisconnect
end sub
- OnPluginSaveState
'
' The plugin is saving its state
'
sub OnPluginSaveState
end sub
- OnPluginEnable
'
' The plugin is being enabled
'
sub OnPluginEnable
end sub
- OnPluginDisable
'
' The plugin is being disabled
'
sub OnPluginDisable
end sub
- OnPluginCommand
'
' The player has typed the command 'sText'
' Return TRUE to process the command, FALSE to discard it
'
Function OnPluginCommand (sText)
OnPluginCommand = vbTrue ' process it
End Function
- OnPluginSend
'
' MUSHclient is sending 'sText' to the MUD
' Return TRUE to send the text, FALSE to discard it
'
Function OnPluginSend (sText)
OnPluginSend = vbTrue ' process it
End Function
- OnPluginLineReceived
'
' MUSHclient has received the line 'sText'
' Return TRUE to process the text, FALSE to discard it
'
Function OnPluginLineReceived (sText)
OnPluginLineReceived = vbTrue ' display it
End Function
- OnPluginPacketReceived
'
' MUSHclient has received the packet 'sText'
'
Sub OnPluginPacketReceived (sText)
End Sub
In the case of routines like OnPluginCommand, each plugin is scanned for every command entered. If any plugin returns FALSE, then that command is not processed. This gives each plugin a chance to respond to various commands, and suppress them if it wants to. Likewise for OnPluginSend and OnPluginLineReceived.
Chat system callbacks - new in version 3.37
- OnPluginChatAccept
' MUSHclient has received a connection from IP,name
' Return TRUE to accept it, FALSE to reject it
'
Function OnPluginChatAccept (sText)
dim theList
dim username, ip
theList = split (sText, ",")
ip = theList (0)
username = theList (1)
End Function
- OnPluginChatMessage
' MUSHclient has received chat message: id, type, text
' Return TRUE to use the default processing, FALSE to ignore it
'
' See the Chat.xml plugin for the exact message numbers that might be received.
Function OnPluginChatMessage (id, message, sText)
OnPluginChatMessage = vbTrue ' process it
End Function
- OnPluginChatDisplay
'
' MUSHclient is about to display message: type, text
' Return TRUE to use the default display, FALSE to not display
'
' See the Chat.xml plugin for the exact message types that might be received.
'
Function OnPluginChatDisplay (message, sText)
OnPluginChatDisplay = vbTrue ' display it
End Function
- OnPluginChatNewUser
'
' A new chat user has been accepted on: id, name
'
'
' This script callback has been provided so you can take action if
' you want (such as allowing file transfers).
'
sub OnPluginChatNewUser (id, name)
end sub
- OnPluginChatUserDisconnect
' This chat user has disconnected for one reason or another.
'
' This callback lets you take action (eg. notify others) however
' you cannot send messages to this connection or change any options
' once they have disconnected. The chat id is supplied so you can
' match the id to the one that connected.
'
' For each call to OnPluginChatNewUser there should eventually be a
' corresponding call to OnPluginChatUserDisconnect.
'
sub OnPluginChatUserDisconnect (id, name)
end sub
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 20 Oct 2002 02:30 AM (UTC) |
Message
| There is now a pointer to this page on the COM functions listing page. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Shadowfyr
USA (1,788 posts) Bio
|
Date
| Reply #2 on Wed 27 Nov 2002 10:27 PM (UTC) Amended on Wed 27 Nov 2002 10:33 PM (UTC) by Shadowfyr
|
Message
| Just occured to me, but what good is knowing a packet or line arrived? Yes, some things can be done with it, but unless we can change the contents of them to say replace < and > with < and > when some mud admins refuse to follow specs, as someone posted about a while back, what good is it really? It would be nice to be able to test for cases where such a replacement is useful and imho makes much more sense doing it on a packet or line level 'prior' to the world getting it, than to make triggers and such do so later on. Just a thought..
Either that or a command like 'world.stream BStr Text', which would treat the sent text as though it was being recieved from the mud. Then you would just do your replacing, etc., pass the fixed bit using world.stream and use OnPluginLineRecieved vbFalse to exclude the original. | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #3 on Thu 28 Nov 2002 01:57 AM (UTC) |
Message
| It wasn't supposed to be fabulously useful, but in the event that you wanted to detect telnet codes, or do other low-level work, you could use that. For instance, you might detect a prompt before the newline appeared. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Shadowfyr
USA (1,788 posts) Bio
|
Date
| Reply #4 on Thu 28 Nov 2002 04:30 AM (UTC) |
Message
| True.. But it did occure to me that being able to use it to replace the actually contents of what the client processes would make a nice power user feature. It would provide the means to do most of what is currently impossible to correct (do to lazy implimentation on muds) as well as a fairly simple means to do things like what magnum wanted and add ,s to numbers and stuff.
Doing many of these things after the line has already been run through the normal process is less than transparent at best and totally pointless to even try at the worst. Exa: the only way to correct invalid tags when a muds admin refuses to correctly use the replacements would be to use a proxy that can trade out one character of others and the odd of one doing that 'and' being able to tell when it shouldn't do it is not terribly good. It doesn't have to be stripped of ansi, since as a power user feature the assumption would be that you had better have a good idea how to deal with those things anyway to be using it. lol
Right now there realy isn't a way to add, remove or replace anything in an incoming line and this would provide a good way to do it, without having to add extra code into triggers that wouldn't be able to solve the some problems anyway. Right now you can look at a packet when recieved, but not alter the contents or ignore it. You can look at a line too, but I assume that ansi and stuff is stripped (or maybe not??) and your only option is to ignore the line. If it is really pre-process, why not a way to modify the contents? It seems a better solution to me than any of the alternatives that exist or are likely in the future.
Though.. Maybe a better choice would be:
BStr OnPluginLineRecievedEx (BStr sText, BStr aText)
where the aText one contains the ansi and you return a string (such as the modified aText) or a null string instead of vbTrue and vbFalse... That way you maintain compatibility, but provide us power users with a way to do what I am suggesting. | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #5 on Thu 25 Jun 2009 09:20 PM (UTC) Amended on Thu 25 Jun 2009 09:22 PM (UTC) by Nick Gammon
|
Message
| |
Posted by
| Fadedparadox
USA (91 posts) Bio
|
Date
| Reply #6 on Thu 25 Jun 2009 10:13 PM (UTC) |
Message
| OnPluginPacketReceived is essential to ATCP support, for IRE MUDs. | 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.
34,707 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top