Plugins
Plugins add features to Realm Lore, such as extra pages in the sidebar. Realm Lore doesn't come with any plugins installed. Plugins are for people comfortable installing or writing JavaScript.
WARNING
A plugin runs with the same access to your Mac as Realm Lore itself. Only install plugins from people you trust, and read the code first if you can.
Install a plugin
- Open Settings > Plugins.
- Under Plugins Folder, click Open. The folder is
~/Library/Application Support/realm-lore/plugins/. - Copy the plugin's folder into it. Each plugin folder has a
manifest.jsonand amain.js. - Click the refresh button next to Open.
- Make sure Enable plugins is on, then turn on the plugin under Installed Plugins.
Plugins that add a page appear under a Plugins heading in the sidebar. Turn off Enable plugins to stop all plugins from loading at once.
Two example plugins are in the source repository: World Stats, which adds a statistics page for the active world, and Example Logger.
Write a plugin
A plugin is a folder containing:
manifest.jsonwith anid,nameandversion, and optionally adescription,authorandmainfile name.- An ES module, usually
main.js, whose default export has anonLoad(api)function and, optionally,onUnload().
{
"id": "my-plugin",
"name": "My Plugin",
"version": "1.0.0",
"description": "Does something useful.",
"author": "You",
"main": "main.js"
}The api object passed to onLoad includes:
| Member | Use |
|---|---|
registerPanel({ panelId, panelFile, navLabel, navIcon }) | Adds a sidebar page. panelFile is a script in the plugin folder that exports a component. |
fs.readFile, fs.writeFile, fs.exists | Read and write files inside the Worlds folder. |
on, off, emit | Send and listen for events shared between plugins. |
log, writeLog | Write messages to the console, or to .plugin-logs/<plugin id>.log in the Worlds folder. |
Settings > Plugins > Writing a Plugin shows a minimal example, and the World Stats plugin in the repository shows how to build a panel.