BroadcastPlugin
Script function

world.BroadcastPlugin

DOC_scripting Read about scripting

Type

Method

Summary

Broadcasts a message to all installed plugins

Prototype

long BroadcastPlugin(long Message, BSTR Text);

DOC_data_types View list of data type meanings


Description

Broadcasts the message to all installed plugins.

The intention here is for one plugin to catch an event and "notify" all other plugins of that event.

You supply 2 arguments, a number and a string.

The number is intended to be a "message number", to indicate the type of message (eg. trigger has fired = 1, alias matched = 2).

The string is intended to allow you to supply free-format data to the plugin.

All installed plugins are checked for a function OnPluginBroadcast. If present, it is called with 4 arguments:

1 - the message number (supplied above).

2 - the ID of the calling plugin, or an empty string if BroadcastPlugin was called from the main script file.

3 - the name of the calling plugin, or an empty string if BroadcastPlugin was called from the main script file.

4 - the Text argument (supplied above)

An example of a plugin handler might be (in Lua):


function OnPluginBroadcast (msg, id, name, text)
Note ("msg = " .. msg)
Note ("id = " .. id)
Note ("name = " .. name)
Note ("text = " .. text)
end


The calling plugin ID and name are supplied so that plugin writers can verify which plugin originated a particular message. This cannot be spoofed as it is supplied automatically by MUSHclient.

Thus, a sensible test might be for a plugin that incorporates an OnPluginBroadcast handler, to test the id supplied to match the id of the plugin that it expects to be doing the broadcast.



VBscript example

world.BroadcastPlugin 100, "Some message"



Jscript example

world.BroadcastPlugin (100, "some message");



PerlScript example

$world->BroadcastPlugin (100, "some message");



Python example

world.BroadcastPlugin (100, "some message")



Lua example

BroadcastPlugin (100, "some message")



Lua notes

The Text parameter is optional, and defaults to an empty string.



Return value

The number of plugins that had an OnPluginBroadcast handler.




See Also ...

Topics

DOC_aliases Aliases
DOC_Arrays Arrays
DOC_plugins Plugins
DOC_scripting Scripting
DOC_timers Timers
DOC_triggers Triggers
DOC_variables Variables

Functions

FNC_CallPlugin CallPlugin (Calls a routine in a plugin)
FNC_EnablePlugin EnablePlugin (Enables or disables the specified plugin)
FNC_GetPluginID GetPluginID (Returns the 24-character ID of the current plugin)
FNC_GetPluginInfo GetPluginInfo (Gets details about a specified plugin)
FNC_GetPluginList GetPluginList (Gets a list of installed plugins.)
FNC_GetPluginName GetPluginName (Returns the name of the current plugin)
FNC_GetPluginTimerInfo GetPluginTimerInfo (Gets details about a named timer for a specified plugin)
FNC_GetPluginTimerList GetPluginTimerList (Gets the list of timers in a specified plugin)
FNC_GetPluginVariable GetPluginVariable (Gets the contents of a variable belonging to a plugin)
FNC_GetPluginVariableList GetPluginVariableList (Gets the list of variables in a specified plugin)
FNC_IsPluginInstalled IsPluginInstalled (Checks to see if a particular plugin is installed)
FNC_LoadPlugin LoadPlugin (Loads a plugin from disk)
FNC_PluginSupports PluginSupports (Checks if a plugin supports a particular routine)
FNC_ReloadPlugin ReloadPlugin (Reloads an installed plugin)
FNC_SaveState SaveState (Saves the state of the current plugin)

(Help topic: function=BroadcastPlugin)

DOC_contents Documentation contents page