Create plugins
A community plugin adds whatever you want to VERB: Logic blocks, your own events, data, a page in the editor or tools for the AI agent. You do not need to see the code of the editor or the engine.
This is the first version of the API. It covers blocks, events, data, forms, your own pages and studios, Assets, per-frame code, keyboard and mouse, drawing over the scene, characters drawn by your plugin and your own fields on characters, scenes and objects. You can also replace parts of the engine: the controller, the camera, the interface and even all the scene drawing. And, with permission, connect to the internet.
They run isolated
A plugin runs in a closed environment: it cannot see the editor or your projects, and it only has network access if it declares it and the player accepts. It only talks to VERB through the API on this page. Installing one warns that VERB has not reviewed it.
Getting started
Download the plugin kit. It brings a working template, the API types (verb-plugin.d.ts) and the packer. You only need Node.js 18 or newer.
node pack.mjs my-folderThat checks the basics and leaves the .verbplugin in the folder.
The package
A .verbplugin is a zip with these files at its root:
| File | What it is |
|---|---|
verbplugin.json | The manifest. Required. |
runtime.js | The code that runs in the game. Required if you declare blocks. |
editor.js | Your page in the editor. It needs the editor-ui permission. It does not reach the exported game. |
The manifest
{
"id": "com.author.achievements",
"name": { "es": "Logros", "en": "Achievements" },
"description": { "es": "Logros para tu juego", "en": "Achievements for your game" },
"author": "Author",
"version": "1.0.0",
"apiVersion": 1,
"minEditor": "0.1.0",
"dataVersion": 1,
"permissions": ["editor-ui"],
"blocks": [
{
"name": "unlock",
"category": "flow",
"label": { "es": "Desbloquear logro", "en": "Unlock achievement" },
"sentence": { "es": "Desbloquear el logro {name}", "en": "Unlock the achievement {name}" },
"params": [{ "key": "name", "type": "word", "label": { "es": "logro", "en": "achievement" } }]
}
],
"panel": {
"form": [{ "key": "title", "type": "text", "label": { "es": "Título", "en": "Title" } }],
"page": true
},
"tools": [
{ "name": "add_achievement", "description": "Adds an achievement.", "inputSchema": { "type": "object" } }
]
}id: it never changes. Lowercase, numbers, hyphens and dots.- Texts: all of them carry Spanish and English. Without English, the plugin does not install.
category:event,condition,flow,scene,variable,dialogue,mediaorcamera. Aconditionbranches yes or no; aneventstarts scripts.- Parameter types:
text,number,boolean,word,choice,item,character,scene,variable,value,soundandimage. - Form field types:
text,number,boolean,choice,scene,item,characterandlist. Each field editsdata[key]. - Permissions:
editor-ui(your own page),read-project(read the names of scenes, items, characters and variables),assets(read, create and replace files in Assets),input(read and capture keys and clicks),surface(draw over the scene),actors(draw characters),write-project(change your fields from your page),write-content(create content) and those for replacing parts of the engine:replace-controller,replace-camera,replace-uiandreplace-render; andnetworkto connect to the internet. fields: adds fields to the editor inspectors, with the same types as the form:"fields": { "character": [...], "scene": [...], "prop": [...], "hotspot": [...] }.panel.studio: instead ofpanel.page, it opens youreditor.jsfull screen, with its entry in the editor menu (under Plugins, in the Community group). It carries its name in Spanish and English:"studio": { "es": "Mi editor", "en": "My editor" }.
In the game: runtime.js
VERB.onBlock('unlock', async ({ name }) => {
const state = (await VERB.getState()) ?? { unlocked: [] };
state.unlocked.push(name);
await VERB.setState(state);
await VERB.game.say('player', `Achievement: ${name}!`);
await VERB.emit('unlocked', { name });
});| Function | What it does |
|---|---|
VERB.onBlock(name, fn) | Answers your block. It receives its parameters. In a condition, what you return decides yes or no. |
VERB.onEvent(fn) | Tells you what happens. type: sceneChanged, variable, itemAdded, itemRemoved, script, gameEnded, loaded. |
VERB.emit(name, data) | Starts the scripts that begin with your event block. The name is the block name: letters, numbers, _ and -, no dots. |
VERB.getState() / VERB.setState(v) | Your state in the save, as JSON (up to 1 MB). It is saved and loaded with it. |
VERB.getData() | The project data your form or page edits. |
VERB.getVariable(n) / VERB.setVariable(n, v) | Game variables, by name. |
VERB.text(key) | A game text in the current language. |
VERB.assetBytes(id) | The content of an asset, as an ArrayBuffer. It needs assets. |
VERB.game.* | The same actions as the code of the scripting API (say, walkTo, goto, attach…), always with await. Nested ones get a flat name: game.items.add is VERB.game.addItem, game.set is setVar and game.camera.pan is cameraPan. What you read (variables, inventory, where everyone is) goes through VERB.game.snapshot(). The kit types bring the whole list with its help. With VERB.game.do("sentence"), check("condition") and block(type, values) you reach any block of the editor, new ones included, even if they have no method of their own. |
VERB.onFrame(fn) | Runs on every game frame, not while paused. It receives dt, time, sceneId, player, pointer, camera and screen (width, height and safeWidth: with the Mobile plugin variable width, width can be larger than the resolution, which is safeWidth). If you fall behind, frames are skipped. |
VERB.input.capture(keys, { pointer }) | You take those keys (KeyA, ArrowLeft…) and, with pointer: true, the clicks: the game no longer handles them. It needs input. |
VERB.onInput(fn) | What you captured: keydown, keyup, pointerdown. |
VERB.input.isDown(key) | Whether a captured key is still held. |
VERB.onActor((actor, canvas) => …) | Draws a character. See Characters. It needs actors. |
VERB.getField(kind, id) | What you stored on a character, scene, prop or hotspot. |
VERB.surface(options) | A canvas between the scene and the interface. It needs surface. See Drawing. |
VERB.log(...) | Writes to the Output window of Test. |
VERB.onTool(name, (args, ctx) => …) | A tool for the agent. ctx.data is your data: change it and it is saved. |
VERB.on('migrate', (data, from) => …) | Moves your data to the new format when you raise dataVersion. |
If your code fails, the game goes on: the error is logged and a condition counts as not met. If it hangs, or sends thousands of messages per second without stopping (a loop that never waits), it stops by itself.
Drawing in the game
const s = await VERB.surface({ width: 64, height: 64, anchor: 'actor', actor: 'player', x: -32, y: -160 });
const g = s.canvas.getContext('2d'); // or 'webgl2'
VERB.onFrame(({ dt }) => {
g.clearRect(0, 0, 64, 64);
g.fillRect(10, 10, 20, 20);
});anchor:screen(screen pixels),world(a point in the scene, follows the camera) oractor(moves with a character).x,y: position, or offset from the character. Withscreen,rightandbottomcount from the right and bottom edges (of what is seen, also with variable width).scene: true: only shows in the scene where it was created.pixelRatio: more resolution.s.canvasis anOffscreenCanvas: it works with 2D or WebGL, and your code can carry Three.js insideruntime.js.- Draw the whole frame every time: once shown, the canvas is left empty. With
onFrameit shows by itself when your function ends; outside it, calls.present(). s.move(x, y),s.show(false)ands.remove()control it. Up to 16 per plugin.
Without OffscreenCanvas
Canvases use OffscreenCanvas, and some older systems do not have it. There, VERB.surface fails with an error: catch it if your plugin can carry on without drawing. If your plugin has replace-ui or replace-render, it is turned off and the game carries on with the engine's interface and drawing, so nobody ends up facing a black screen. Characters drawn by a plugin show their normal art.
The same happens with any uncaught error while you have something replaced, such as WebGL failing to start on a computer without graphics acceleration.
Characters drawn by your plugin
With the actors permission, your plugin can draw a whole character. For the game it is still a character: it walks, talks, sorts by depth, scales with perspective and takes the scene light. You choose it in the character sheet, under Drawn by a plugin.
VERB.onActor((actor, canvas) => {
const g = canvas.getContext('2d');
// actor: id, character, anim ('idle', 'walk'…), facing ('left'…), loop, width, height, params
g.clearRect(0, 0, actor.width, actor.height);
g.fillRect(0, 0, actor.width, actor.height);
});
VERB.setActorDurations('character_id', { wave: 1.2 });- The feet go at the bottom center of the canvas.
- The canvas is 256×512. To change it, the character's
paramscarrieswidthandheight. - An animation lasts 1 s unless you say otherwise with
setActorDurations. - If your plugin is missing or fails, the character shows its normal art. Without the plugin, the game does not export.
Replace parts of the engine
The engine keeps the logic: scripts, state, conversations, inventory and saves. You keep whatever you take. If your plugin fails, the engine takes all of it back and the game goes on.
| Function | Permission | What it does |
|---|---|---|
VERB.player.take() | replace-controller | Clicks no longer move the main character: they reach you. |
VERB.player.move(dx, dy, anim) | replace-controller | Moves it within the walkable area. It returns where it ended up. |
VERB.player.anim(name) | replace-controller | Sets its animation; null gives it back to the engine. |
VERB.interact(verb, x, y) | replace-controller | Like a click with that verb at that point of the scene. |
VERB.interactWith(action, kind, id) | replace-controller | The same without a point: kind is character, prop or hotspot. The action is a verb, or { item } to use an inventory item. |
VERB.camera.take(), set(x, y, zoom), release() | replace-camera | You drive the camera. |
VERB.ui.take(parts) | replace-ui | Takes mainMenu, pauseMenu, menuButton (the ☰ button), lines, choices, inventory, verbs or hover. |
VERB.ui.onLine(fn) | replace-ui | Shows a line: { character, name, text }. The game waits for your function to end. |
VERB.ui.onChoice(fn) | replace-ui | Shows options: it receives the list and returns the chosen number. |
VERB.ui.startGame() | replace-ui | Starts the game from your menu. |
VERB.ui.continueGame() | replace-ui | Continues the latest game. Returns false if there is none. |
VERB.ui.saves() | replace-ui | The saved games: slots, latest (the one Continue resumes) and canSave. slot 0 is the autosave. |
VERB.ui.save(slot, name), load(slot) | replace-ui | Saves (slots 1 to 3) or loads. They say whether it worked. |
VERB.ui.pause(), resume(), quit() | replace-ui | Opens or closes the pause, or goes back to the main menu. |
VERB.ui.screen(name) | replace-ui | Opens an engine screen: save, load, options or credits. |
VERB.render.take() | replace-render | The engine's drawing is hidden: you paint the whole scene on a surface. |
VERB.render.scene() | replace-render | The current scene: layers, objects with their size, zones (objects and zones carry onlyFor, the characters who see them, and forMe, whether this computer's protagonist sees them: what is not for me is neither drawn nor clicked), lights, characters, walkable floor, obstacles, entrances, regions, scaling, weather and 3D camera. It also arrives every frame as world. |
With replace-render and Three.js inside runtime.js you can make a fully 3D game on top of VERB's logic. Clicks keep working with the scene hotspots. If a click in your 3D view does not land on them, work out which object was hit yourself and use VERB.interactWith.
Your own menus
With pauseMenu and mainMenu the engine does not draw those menus: it tells you through events and you draw them on a surface. While one of your menus is open you get the keys and clicks you captured, and your frames keep running.
await VERB.ui.take(['mainMenu', 'pauseMenu', 'menuButton']);
await VERB.input.capture(['Escape', 'Enter'], { pointer: true });
VERB.onEvent((e) => {
if (e.type === 'pause') showPause();
if (e.type === 'resume') hideMenu();
if (e.type === 'mainMenu') showMenu();
});
VERB.onInput((e) => {
if (e.code === 'Escape') VERB.ui.pause();
});The events are pause, resume, mainMenu and screenClosed, which arrives when leaving a screen opened with VERB.ui.screen. Capture the pointer only while a menu is open: if you capture it during play, clicks do not reach the game. If your plugin crashes with a menu open, the engine shows its own so the player is not left without a way out.
Tools in the Scene editor
With sceneTools in the manifest, your plugin adds buttons to the Scene editor toolbar. Each one places points (point) or zones (polygon) in the scene. No editor code is needed.
"sceneTools": [
{ "name": "sign", "kind": "point", "color": "#22d3ee",
"label": { "es": "Cartel", "en": "Sign" },
"hint": { "es": "Clic donde va el cartel.", "en": "Click where the sign goes." } }
]In the game, read them with await VERB.sceneMarks('sign'), which returns the list for the current scene; pass an id as the second value for another scene. A point is { x, y } and a zone is a list of points. In editor.js they are in VERB.getField('scene', id), under $marks. Authors remove them with a right-click on the canvas or from Plugin marks in the scene tab.
Create content
With write-content, your page can create and change scenes, characters, items, variables and scripts: an importer, a level generator or a wizard fit here.
const scene = await VERB.content.create('scene', { name: 'Room' });
const item = await VERB.content.create('item', { name: 'Coin', description: 'It shines' });
await VERB.content.create('variable', { name: 'coins', type: 'number' });
await VERB.content.update('scene', scene.id, { note: 'Made by my plugin' });
await VERB.content.scripts('=== Start (Global)\nOn game start:\n Set coins to 3.');| Function | What it does |
|---|---|
VERB.content.list(kind) | { id, name } of each scene, character, item or variable. |
VERB.content.get(kind, id) | A full copy, in the project format. |
VERB.content.create(kind, data) | Creates one. It needs name; in a variable, type is number, string or boolean. |
VERB.content.update(kind, id, changes) | Changes those fields. |
VERB.content.remove(kind, id) | Asks to delete it: the person using the editor confirms, with the notice of where it is used. It returns whether it was deleted. |
VERB.content.scripts(text) | Creates scripts in human-readable form. It replaces those with the same name. If they cannot be understood, it returns errors and changes nothing. |
- It can be undone: each call is one Ctrl+Z step, and it saves like any other change.
- Texts (
nameof characters and items,descriptionof items) are written as plain text. - Data shape: a field cannot change type, and if the project could not open, the call fails and changes nothing. The
idcannot change, norextorextDriver. - It only exists in your
editor.jspage: content cannot be created during the game.
Connect to the internet
"permissions": ["network"],
"network": ["https://api.example.com", "wss://room.example.com"]With that, fetch and WebSocket work in runtime.js, only towards those addresses.
- They are
https://orwss://origins, without paths or wildcards. To test on your computer,http://localhostis allowed. - The player decides: the first time, the game asks. If they say no, your plugin starts without network, so expect it to fail.
- Your server has to accept the
nullorigin through CORS: the plugin runs isolated and has no origin of its own. - WebRTC is not available: for multiplayer, use a room server over WebSocket.
- Your
editor.jspage has no network, and neither do the agent tools. - It cannot load outside code: what you run goes inside
runtime.js. - With VERB Runner, desktop games need a recent Runner. On an old one, your plugin has no network.
In the editor: editor.js
Your page runs in an isolated frame with almost everything the browser offers: canvas, WebGL, Web Audio, workers. An audio or map editor fits here. It has no network or outside resources, it cannot navigate to another address and it cannot create frames with their own scripts.
const data = (await VERB.getData()) ?? {};
document.body.textContent = VERB.lang === 'es' ? 'Hola' : 'Hello';
await VERB.setData({ ...data, opened: true });
await VERB.setHeight(600);| Function | What it does |
|---|---|
VERB.lang | Editor language: es or en. |
VERB.getData() / VERB.setData(v) | Reads and saves your data (5 MB of JSON at most: it travels with the project and the game). Saving can be undone. |
VERB.setHeight(px) | The height of your page. |
VERB.project() | Names of scenes, items, characters and variables. It needs read-project. |
VERB.getField(kind, id) / VERB.setField(kind, id, value) | Your fields on a character, scene, prop or hotspot. Writing needs write-project. |
VERB.setDriver(character, params) | Makes your plugin draw that character. It needs actors. |
VERB.assets.list() | The project assets: id, name, kind, mime, size, folder. It needs assets, like the next three. |
VERB.assets.read(id) | The content of an asset, as an ArrayBuffer. |
VERB.assets.create(name, bytes, folder) | Creates an asset from an ArrayBuffer. Its type comes from the content and the name. |
VERB.assets.replace(id, bytes) | Replaces the content. The id stays, so whatever uses it updates, and it can be undone. |
Test and publish
- In Plugins → Summary, turn on Developer mode.
- Click Load folder (Chrome, Edge or VERB Studio Desktop) and pick the plugin folder. It reloads every time you save.
- When it works, pack it with
node pack.mjs my-folder, which checks the texts and leaves the.verbpluginin the folder. Without Node, zip the files, with them at the root, and change the extension to.verbplugin.
Whoever installs it uses Plugins → Import plugin. The plugin travels inside the project and the exported games.
How your page looks
Your page starts with the VERB theme: dark, with its font, and with button, input, select, textarea and canvas styled like the editor. To make it look like a real studio, use these classes:
<div class="verb-app">
<header class="verb-header"><h1>My studio</h1><button class="primary">Save</button></header>
<div class="verb-layout">
<main class="verb-stage"><canvas width="640" height="360"></canvas></main>
<aside class="verb-panel">
<label class="verb-field"><span>Size</span><input type="range"></label>
</aside>
</div>
<p class="verb-status">Ready</p>
</div>| Class | What it is |
|---|---|
verb-app | The whole page: header, content and status line. |
verb-header | Title on one side, actions on the other. |
verb-layout | Content and a settings column. On narrow screens, one below the other. |
verb-stage | Dark background for a canvas. |
verb-panel | A card. |
verb-field | Label and control. |
verb-row | Things in a row. |
verb-list | List with separators. |
verb-muted, verb-status | Secondary text and status line. |
primary | On a button, the main button. |
For your own CSS, the colors are in variables: --verb-bg, --verb-panel, --verb-border, --verb-text, --verb-muted, --verb-primary and --verb-on-primary.
Exporting video
What you paint on surfaces shows up in a cinematic video. The video is made frame by frame, slower or faster than real time, so animate with dt and time from VERB.onFrame, not with performance.now() or requestAnimationFrame. The player is not asked about the network when exporting video: the plugin starts without it.
Details worth knowing
- Your own events: a block with
"category": "event"has no preceding output: it starts scripts. Itssentencereads like "When an achievement is unlocked". You fire it withVERB.emit('name'), using itsname. If the script needs a value, leave it first in a variable withVERB.setVariable. textandword:textis a text that gets translated with the game and appears in Texts;wordis a literal word, untranslated, for keys and internal names.minEditor: minimum VERB Studio version. It is optional.docs: your documentation, anhttpsaddress or one per language ({ "es": "…", "en": "…" }). The editor's documentation button and F1 go there while your plugin is showing; without it, to the plugins home.panel:form,pageandstudiocan go together. The form shows on the plugin page, and the studio reads that same data withVERB.getData().VERB.assets.create: the name carries its extension (card.png), because the type comes from it and from the content. Without a folder, it goes to the root of Assets. A PNG becomes an image.canvas.toBlobworks in your page.- Placing a surface: with
screen,xandycount from the top left;rightandbottomcount from the other edge.frame.screencarries the screen size. - Per-frame cost: every
VERB.*call withawaitis a message to the game. Do not readgetState()every frame: keep a copy in your code and update it when it changes. - Keys: register
onInputbeforecapture. AsayinsideonInputdoes not stop scripts already running. - Types and manifest:
verb-plugin.d.tsis forruntime.js,verb-editor.d.tsforeditor.js, andverbplugin.schema.jsonautocompletes the manifest.
What a plugin cannot do
Your code runs isolated from the game: that is why someone else's plugin cannot read anyone's projects or saved games. That isolation has a price, and it is worth knowing before you start.
- In the game you only draw on canvases. A surface is an
OffscreenCanvas: there is no HTML or CSS there. A menu, an inventory or a dialogue of your own is painted by you, letter by letter. You get no browser text fields or phone keyboard, no Tab navigation and no screen readers. If you need those, leave that part to the engine (VERB.ui.screen) or to UI PRO. The editor is different: your page and your studio are HTML. - You run one frame behind. Every
VERB.*call is a message to the game and its answer arrives later. In an adventure nobody notices; very tight action controls would. Do not wait for the answer ofVERB.player.movebefore painting. - No sound of your own in the game. You can play the game's sounds and music (
VERB.game.sound,music,loopSound…), but you cannot generate or process audio live: there is no Web Audio whereruntime.jsruns. There is in your editor page. replace-renderdoes not save the engine's drawing. Taking the render means you stop seeing what the engine paints, but the engine keeps painting it. A full 3D game pays for both: keep it in mind on modest phones and measure before you grow.- The rules belong to the engine. You can keep the clicks and decide what to do, but what happens on "use X with Y" (scripts, locks, reactions) is decided by the engine.
Compatibility
apiVersion is the version of this API. Within a version things are only added, so what you make today keeps working. If a plugin asks for a version newer than the editor's, it does not install.