Repository navigation
Home
Welcome to the plugin development guide for MSE (Music Sheet Editor)!
This guide will help you make your own plugins for MSE (Music Sheet Editor). This wiki contains the best practices, handy tips, and detailed examples ranging from simple setups to more advanced concepts.
- Plugin Structure
- Getting Started
- Writing Your First Plugin
- Advanced Topics
- Object Names (coming soon)
Each plugin should follow this folder structure:
my-plugin/
├── script.js # Main plugin logic
├── README.md # The readme file of your plugin
└── info.txt # This file should contain the version of your plugin usually in a format like `{"version":1.0}`
- Create a new folder in your
plugins/directory. - Add the required files (
script.js,README.mdandinfo.txt). - Open your app, and open a project. Navigate to the 3 vertical dots on the top-right of the screen and click it and then click script. Copy-paste your script.js code into script textarea and close it. Now your plugin should be loaded into the tool.

While writing your first plugin, you gotta make sure that you know GDJS (GDevelop JavaScript API) since this software is built using GDevelop.
Check out the GDJS docs here:
Even if you don't know much about the API, you should at least grasp the basics of JavaScript, HTML and CSS.
When you're making a plugin, it usually falls into one of these two categories:
-
Menu-Based Plugin
Plugins that show up in the interface (like buttons or tools) and perform tasks when the user interacts with them. -
Background Plugin
These plugins run silently in the background and perform tasks automatically, like analyzing the chart or modifying data behind the scenes.
or maybe even a hybrid of both the categories but, you only have to know the above ones because both requires different approaches with the menu based plugin being the most hardest compared to the background based plugin.
Let's start off with the Background Plugin since it's the easier one to implement. It only runs in the background and performs a specific task when the conditions are met.
Here is an example of a background plugin made by Michael:
if(runtimeScene.getOnceTriggers().triggerOnce(1)){
registerTxt('event_display',true,false,30)
runtimeScene.createObject('event_display').setPosition(415,34)
runtimeScene.getObjects('event_display')[0].setLayer('Layer')
}
runtimeScene.getObjects('music_container').forEach(obj=>{if(gdjs.RuntimeObject.collisionTest(obj,runtimeScene.getObjects('play_node')[0],true)){
runtimeScene.getObjects('event_display')[0].setString(obj.getVariables().get('data').getAsString())
}})
see eventsplugin source code made by Michael
Let's understand this code piece by piece
The code is wrapped in a triggers once so that it won't execute repeatedly in a loop
Note: GDevelop executes the code in a loop so if we want something to only trigger once, wrap it in a
trigger onceas shown in the example.
So after making sure that it only executes once, we create a text input at the x position: 415, and y position: 34.
- This is the text in which we will display the event name of the node.
runtimeScene.getObjects('music_container').forEach(obj=>{if(gdjs.RuntimeObject.collisionTest(obj,runtimeScene.getObjects('play_node')[0],true)){
runtimeScene.getObjects('event_display')[0].setString(obj.getVariables().get('data').getAsString())
}})This code first gets all objects named music_container (the playhead) and then for each music_container object on the screen, we would check if any of them collides with the play_node object (the node), and if it collides then we would change the string value of the text that we created before to the name of the node.
If you are wondering what the names of specific objects are, then you can skip over to [Object Names](#object-names) to find it out
This is the more complex part. GDJS doesn't directly support creating sprites or objects in the screen other than texts and other minor things.
But we can make a menu by tricking GDJS into loading an [iframe](https://www.w3schools.com/TAGS/tag_iframe.asp) with HTML5 code by injecting HTML code into an iframe.
Here is a simple example:
document.addEventListener("keydown", function (event) {
if (event.ctrlKey && event.shiftKey && event.key.toLowerCase() === "s") { // add a custom keybind so that you can open your menu
if (!document.getElementById("add-your-own-unqie-iframe-id")) {
const iframe = document.createElement("iframe");
iframe.id = "add-your-own-unqie-iframe-id";
iframe.style.width = "340px"; // add your own width
iframe.style.height = "280px"; // add your own height
iframe.style.border = "2px solid #8A2BE2"; // style, you can choose your own
iframe.style.borderRadius = "10px";
iframe.style.position = "fixed";
iframe.style.top = "50%";
iframe.style.left = "50%";
iframe.style.transform = "translate(-50%, -50%)";
iframe.style.background = "#2D1B5A"; // style, you can choose your own
iframe.style.zIndex = "1000";
document.body.appendChild(iframe);
iframe.srcdoc = `
<html>
<head>
<title>Example</title>
</head>
<style>
/* css style */
</style>
<body>
<script>
// your script
</script>
</body>
</html>
`;
/* const iframeHtml = `` // IF USING THIS PASTE THE HTML IN HERE.
const blob = new Blob([iframeHtml], { type: "text/html" });
iframe.src = URL.createObjectURL(blob);
This also works, you can use this if you dont want to use srcdoc.
IF YOU NEED TO SAVE SOMETHING TO LOCALSTORAGE OR OTHER SAVING SYSTEMS, THEN USE SCRDOC
IF YOU NEED TO POST/RECEIVE MESSAGES BETWEEN PARENT (THE MAIN DOCUMENT) AND THE CHILD (THE IFRAME)
*/
}
}
});
This example opens up a menu when we press ctrl+shift+s. If you press it, nothing will appear other than the iframe since the HTML is just bare bones and has no elements or style.
iframe.style.width = "340px"; // add your own width
iframe.style.height = "280px"; // add your own height
iframe.style.border = "2px solid #8A2BE2"; // style, you can choose your own
iframe.style.borderRadius = "10px";
iframe.style.position = "fixed";
iframe.style.top = "50%";
iframe.style.left = "50%";
iframe.style.transform = "translate(-50%, -50%)";
iframe.style.background = "#2D1B5A"; // style, you can choose your own
iframe.style.zIndex = "1000";These are the default styles that we applied to the iframe while creating it.
The basics of creating a plugin is not always helpful in more complex plugin's so, the advanced topics will help you the most in making a complex plugin.
Sometimes you might not always be able to do complex functionalities on your own, so you would reside to using JavaScript Libraries.
Integrating libraries is an easy task because we can just do <script stc="https://cdn.deliveringsite/library.min.js"></script> and start using the library! But it requires internet connection. MSE (Music Sheet Editor) is an offline software and user's might not always be connected to the internet, so if you want to make your plugin offline, you can try to convert the library source code into a base64 data uri format and then integrate it into your project. This can be a bit hard for some people so let's understand on how to access the library faster and offline!
- First of all download the javascript file of the library. It should be in the
.jsfile extension.
NOTE: If your library relies on multiple files to function then unfortunately you wont be able to run your library offline!
Now after you have the JavaScript source code of the library, convert it into the base64 format by either using CyberChef or Base64 Guru. If both doesn't work, then try searching for a JavaScript to Base64 converter online.
const CodeBase64 = "<your base64 encoded string>"
const decodedCode = atob(CodeBase64);
const CodeBlob = new Blob([decodedCode], {
type: "application/javascript",
});
const CodeBlobUrl = URL.createObjectURL(CodeBlob);This is the example code that you should have in your plugin script.
Now load the library by loading the blob in the html.
<script src="${CodeBlobUrl}"></script>This will load the library if everything went right.
MSE (Music Sheet Editor)