-
-
Notifications
You must be signed in to change notification settings - Fork 2
Module Guide
Ender edited this page Jan 9, 2021
·
1 revision
Make a file called modules.json
, have this be the contents:
{
"supported": [
"1.*-*"
],
"unsupported": [
"0.4.*-*",
"0.5.*-*"
],
"version": "1.0.0",
"name": "My Module",
"scripts": [
"mymodule.js"
],
"simple": [],
"required": [
{
"namespace": "my_example_module",
"id": "my_module"
}
]
}
Then create a file called mymodule.js
, and have this be the contents:
MODULES.moduleClasses["my_example_module"] = class {
constructor(id) {
this.namespace = "my_example_module";
this.type = "overlay settings"; // A overlay or widget goes in the left side, settings means it'll have a config page.
// If you want the module to appear in settings than just have this be settings.
// If you want a standalone page (Like the Support Us page), change this to "application"
this.id = id;
}
widgetDisplay = [
{
name: "Test",
icon: "dice",
onclick(instance) {
alert("Widget display test");
}
}
]
getDataToStore() {
return this.settings;
}
// For communicating with weboverlays, refer to the ones built into Caffeinated for some more info.
onConnection(socket) {
MODULES.emitIO(this, "config", this.settings, socket);
}
init() {
console.debug("[MyModule] Init!");
}
onSettingsUpdate() {
alert(this.settings.alert);
MODULES.emitIO(this, "config", this.settings);
}
// Refer to the built in modules for some more advanced settings.
settingsDisplay = {
alert: "input"
};
defaultSettings = {
alert: "Test!"
};
};