Getting started - lmparppei/BeatPlugins GitHub Wiki
Writing a Basic Plugin
Plugins are written in pure JavaScript. You can access Beat using an object called Beat
.
For development purposes, you can open the plugin console using Beat.openConsole()
and log stuff into it using Beat.log()
.
Plugin File
Select Tools → Plugin Library and click on the folder icon on the right. This will open up your local plugin folder. Create a folder called
Your Plugin.beatPlugin
and a new empty file called plugin.js
under it (or, alternatively a file with the same name, ie. Your Plugin.beatPlugin/Your Plugin.beatPlugin
).
You should now have a file like this:
Plugins/Your Plugin.beatPlugin/plugin.js
When you close the Plugin Library, a new plugin will appear under Tools called Your Plugin.
Writing the Code
Note: See the included samples to get a general idea on how plugins are written
This code gets an input from the user and adds it at the end of current document.
// Open console for debugging
Beat.openConsole()
let characterName = Beat.prompt("Character name", "The name of your character", "Doe")
let dialogue = Beat.prompt("Line of dialogue", "What should they say?", "Hello World!")
// Do nothing if the user didn't give any input
if (!dialogue.length || !characterName.length) return;
// Get the length of text
let location = Beat.getText().length
// Add a dialogue block at the end of document
Beat.addString("\n\n" + characterName.toUpperCase() + "\n" + dialogue + "\n\n", location)
// Show data in console
Beat.log("Character name: " + characterName + " Dialogue: " + dialogue)
Writing plugins is this easy! You can now expand your creation and do weird and wonderful tools for yourself and others to enjoy.
Distributing Plugins
When you are done with your plugin, either zip it and distribute to users as-is, submit a pull request into this repository, or send it via e-mail to get it featured in the Plugin Library.
Read Plugin Guidelines for further info.