plugin
namespace plugin
Public Methods
get(classType: object | string) → {BasePlugin}
returns the the plugin instance with the specified class type or registered name
Name | Type | Description |
---|---|---|
classType | object | string |
the Class Object or registered name of the plugin to retreive |
Type | Description |
---|---|
BasePlugin |
a plugin instance or undefined |
patch(proto: object, name: string, fn: Function) → {}
patch a melonJS function
// redefine the me.game.update function with a new one
me.plugin.patch(me.game, "update", function () {
// display something in the console
console.log("duh");
// call the original me.game.update function
this._patched();
});
Name | Type | Description |
---|---|---|
proto | object |
target object |
name | string |
target function |
fn | Function |
replacement function |
register(plugin: BasePlugin, name: string, args: unknown) → {}
Register a plugin.
// register a new plugin
me.plugin.register(TestPlugin, "testPlugin");
// the `testPlugin` class instance can also be accessed through me.plugin.cache
me.plugin.cache.testPlugin.myfunction ();
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
plugin | BasePlugin |
Plugin object to instantiate and register |
||
name | string |
<optional> |
plugin.constructor.name |
a unique name for this plugin |
args | unknown |
<optional> |
all extra parameters will be passed to the plugin constructor |