Posted by
| Nick Gammon
Australia (22,990 posts) bio
Forum Administrator |
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 |
|