Request by sending an email to developer@vatom.com
Before creating a plugin, make sure you have gone through the preparation steps listed in the Overview.
To create a new plugin, run the command vatom plugin new
and follow the on-screen instructions. This should create a new directory with this content:
File | Description |
---|---|
/src | This folder contains all the Javascript code for your plugin. |
/src/index.js | This is the entry point into your plugin. This file must export a default class which subclasses BasePlugin . |
/resources | This contains any resource files that should be available to your plugin. During runtime, you can get a URL to a resource using the paths.absolute() API. |
/icon | This folder must contain a single PNG icon, sized to 200x200. This icon will be displayed on the Vatom Market. This is required when publishing plugins. |
/gallery | This folder contains the images to display on your Vatom Market listing. The images must show an example of your plugin being used and what it does. This is required when publishing plugins. |
/vatom.lock | Contains details about your plugin to use when publishing to the Vatom Market. |
It also generates a Webpack environment for your plugin, which means you are able to use any NPM package via ES6 imports. The available commands you can run within your plugin's directory are:
npm install
: Installs dependencies. Make sure to run this first.
npm start
: Starts a temporary dev server hosting your plugin.
npm run publish
: Publishes your plugin to the Vatom Market.
This is the main class of your plugin, and the first one loaded by Spaces. This class must be exported by /src/index.js
.
export default class MyPlugin extends BasePlugin {
/** Plugin info */
static id = "com.mycompany.myplugin"
static name = "My Plugin"
/** Called on load */
onLoad() {
// Create a button in the toolbar
this.menus.register({
icon: this.paths.absolute('button-icon.png'),
text: 'My Plugin',
action: () => this.onButtonPress()
})
}
/** Called when the user presses the action button */
onButtonPress() {
// Show alert
this.menus.alert(`Hello from ${MyPlugin.name} version ${require('../package.json').version}!`, 'Hello world!', 'info')
}
}
The plugin example that is created for you simply creates a button in the bottom nav bar called "My Plugin", which shows an alert when clicked.
When developing a plugin, you can sideload it and bypass the Vatom Market for testing. Follow these steps to test your new plugin:
npm install
to install dependencies if you haven't yetnpm start
to start a local serverNote: When running a plugin this way, the plugin will only load for you. Anyone else who visits the space on a different machine will not be able to load the plugin.
A plugin will generally go through a couple lifecycle events, which you can use to provide functionality.
These are from the BasePlugin
class and include:
onLoad()
- First event called when the plugin loads. This is normally where you would register your UI menus and components.onSettingsUpdated(field, value)
- Called when a user has changed a setting in your plugin.onUnload()
- Called when your plugin is about to be removed.Find out how to attach logic to an in-world object by creating a Component, or read through the API Documentation.