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

MUSHclient scripting

Description of MUSHclient world function: world.BroadcastPlugin


Name BroadcastPlugin
Type Method
Summary Broadcasts a message to all installed plugins
Prototype long BroadcastPlugin(long Message, BSTR Text);

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.


Note: Available in version 3.67 onwards.


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.
Returns The number of plugins that had an OnPluginBroadcast handler.
Introduced in version 3.67

See also ...

Function Description
CallPlugin Calls a routine in a plugin
GetPluginID Returns the 24-character ID of the current plugin
GetPluginInfo Gets details about a specified plugin
GetPluginList Gets a list of installed plugins.
IsPluginInstalled Checks to see if a particular plugin is installed
LoadPlugin Loads a plugin from disk
PluginSupports Checks if a plugin supports a particular routine

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.


Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes


Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes


View all functions

[Back]

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

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]