Plugin API level 2: settings creators can change, bundled art, opening game windows, hiding HUD parts, keys and storage.
Client Plugin Settings, Art & Game Windows
Plugin API level 2 lets a client plugin do what a real HUD replacement needs. It can:
- ship its own art;
- let creators change its look and behaviour without touching code;
- open the game's own windows, or show them inside its own UI (a phone screen);
- hide or move parts of the default HUD;
- add a key players can rebind;
- remember small things per player.
The GTO Phone HUD is built entirely on this.
Where to author it#
- Open the editor's Plugins page.
- Create a plugin, or Import a
.ed5pluginpackage (see Sharing Plugins). - Click the plugin's ⚙ Settings & sharing button in Project plugins. Its tabs are Settings, Assets, README & licence and Share.
Set it up#
- Make sure the plugin runs on the client (
runs: ["client"]). Plugins from a package already do. - Grant only the capabilities it uses (table below).
- Set its options on the Settings tab, then Save settings.
- Turn it on with the power button. Players get it, and any settings change, on their next login. There is nothing to publish.
Capabilities#
A project plugin can only call these methods when the matching capability is granted. A missing capability logs a warning once, and the call does nothing.
| Capability | Risk | Unlocks |
|---|---|---|
ui:hud | R1 | HUD widgets (createWidget) |
ui:panels | R0 | ctx.openPanel(id), ctx.hostPanels(…), ctx.getPanelHost(), ctx.onPanelHostChange(fn), ctx.closePanel(id?), ctx.toggleHostedPanelDrawer(id, drawer) |
ui:hud-layout | R1 | ctx.setHudElement(id, …), ctx.getHudLayout(), ctx.onHudLayoutChange(fn) |
input:keys | R0 | ctx.registerKeybinding(…) |
storage:client | R0 | ctx.storage |
The new ctx methods#
| Method | What it does |
|---|---|
ctx.getSettings() | Returns the creator's settings. Every key of the plugin's settings schema is there: the saved value, or the default when nothing valid is saved. |
ctx.assetUrl(name) | Returns a URL for one of the plugin's own files, e.g. ctx.assetUrl("phone-frame.webp"). Use it as an <img src> in a widget. Returns "" when there is no such asset. |
ctx.listAssets() | Returns the names of the plugin's files. |
ctx.openPanel(id) | Opens or closes a game window. Ids: inventory, character, skills, abilities, quests, map, worldMap, locations, achievements, pets, market, store, bank, mail, guild, friends, emotes, crafting, calendar, library, settings, keybinds, fishJournal. It follows the same rules as the game's own buttons, so a window whose system is off stays closed. |
ctx.setHudElement(id, override) | Hides, moves or scales one of the game's HUD elements for this player: { visible, anchor, x, y, scale }. Anchors are tl tc tr bl bc br center; x and y are px from the anchor; scale runs 0.25–3. Add clip: { x, y, w, h, radius } (viewport px) to show only part of the element. A phone HUD uses it to frame the minimap in its GPS window without the minimap's own edges or buttons. (Level 4, minimap only.) follow: true keeps the player in the middle of the map even when the creator's zoom fits the whole map; viewTiles: 48 shows that many tiles across (8–1000) whatever the map's size. A GPS window that shows only the middle of the minimap needs both, or the player walks out of view. Pass null to give it back. Ids are the HUD layout ids: minimap, hpBar, mpBar, staminaBar, bountyReadout, questTracker, chat, abilityBar, and so on. Everything is undone when the plugin unloads. |
ctx.getHudLayout() | (Plugin API level 3.) Where the game's HUD sits right now: { viewport, elements, minimap }. elements maps each HUD id on screen (minimap, hpBar, chat…) to { left, top, width, height, scale } in viewport px, with the layout's scale already applied. minimap is { sizePx, markerScale, rect }: the map's real size (the creator's Minimap → Size, phone-capped), its Marker size, and its box — or null while no minimap is shown. A phone HUD reads the minimap's size from here instead of asking the creator to type it again. Returns null without ui:hud-layout. |
ctx.onHudLayoutChange(fn) | (Level 3.) Calls fn(layout) when a HUD element moves, resizes, appears or goes, or the minimap's size changes — once per relayout. Returns an unsubscribe function. |
ctx.hostPanels({ frame, exclude, minWidth, drawerButtons }) | (Plugin API level 4.) Shows the player's own game windows inside your UI instead of floating: the bag, character, skills, quests, map, crew, settings, keybinds and the rest open in frame ({ x, y, w, h, radius }, viewport px). They are the real windows, with every feature they have; only their place changes. Each is laid out at least minWidth px wide (240–900, default 380) and scaled to fit, and the newest one is on show. Call it again to move or resize the frame; null stops. One plugin hosts at a time: it returns false when another already does. See What stays a normal window below. |
| ctx.toggleHostedPanelDrawer(panelId, drawer) | Opens or closes a side drawer of a hosted window as a sheet inside the frame. Today that is the bag: ("inventory", "stats") for character stats and ("inventory", "pets") for pets. By default the game draws two small buttons for them on the frame's right edge; pass drawerButtons: false to ctx.hostPanels to hide those and open the drawers from your own buttons with this call. Returns false when your plugin is not the host, the window is not in the frame, or it has no such drawer. Check typeof ctx.toggleHostedPanelDrawer === "function" first: older engines do not have it. |
| ctx.getPanelHost() | (Level 4.) { active, panels, top, world }: the windows in your frame now ([{ id, title }], oldest first), the one on show, and the world windows open now (while any is, nothing is hosted). |
| ctx.onPanelHostChange(fn) | (Level 4.) Calls fn(state) when a window opens in or closes from your frame, or a world window turns hosting off. A phone uses it to slide up and draw its title bar. Returns an unsubscribe function. |
| ctx.closePanel(id?) | (Level 4.) Closes a hosted window the way its own close button does: id, or the one on show. Your Back button calls it. |
| ctx.registerKeybinding({ id, label, defaultKey }, fn) | Adds a key. defaultKey is a key code: Quote, KeyP, F2, Backslash, Home… The key never fires while the player is typing. Players can rebind it in Keybinds → Plugins. Each plugin can register up to 8 keys. |
| ctx.storage.get/set/remove/keys | Small string values kept in this player's browser, separate for each plugin. Up to 64 keys, 8 KB each. |
| ctx.getState(keys) | Pass the field names you need, e.g. getState(["selfHp", "worldClock"]), to get only those. A HUD that re-renders often should do this: copying the whole state (every entity in view) is the slow part of a sandboxed plugin's frame, and each call has a 50 ms budget. |
| ctx.hasCapability(id) | Tells you whether a capability was granted, so the plugin can degrade gracefully. |
HUD layer. Pass layer: "hud" to createWidget for a widget that is part of the HUD. It sits with the game's own HUD, above its bars and the minimap, and below every game window, so the bag or map it opens is never covered. The default, "overlay", sits above everything.
Clicks. A widget's onClick now receives { action }, the data-action of the element that was clicked. One widget can hold many buttons: <div data-action="bag">.
New getState() fields. selfStamina, selfMaxStamina, wantedStars (0–5), totalBounty, bounties, pursuit ("chasing", "searching" or null), localFactionId, worldTime, worldClock (e.g. "21:47"), viewport ({ width, height }) and openWindows (the game windows open now: inventory, worldMap, bank, settings…). onStateChange also fires when a window opens or closes, so a HUD can step aside while one is up.
What stays a normal window#
ctx.hostPanels hosts the player's own menus. These never go in the frame:
| Kind | Windows | While open |
|---|---|---|
| World windows: opened by talking to someone or using something | NPC dialogue, event messages, bank, shop, chest, trade, crafting, enchant, upgrade, repair, affix reroll, currency exchange, taming, pasture, breeding, farming, instances, inspect, minigames, build mode | Nothing is hosted. The whole interaction plays out as it does without the plugin (the bag opens beside the bank as usual). A phone steps aside: state.world is not empty. |
| Any window an NPC or a map event opens | e.g. the market an auctioneer opens, a menu an event's Open menu command opens | Treated as a world window, whatever its id. |
| Prompts and full-screen moments | confirm boxes, quantity pickers, loot rolls, connection, death recap, logout countdown, onboarding, pet battles | Never hosted; hosted windows stay put. |
Add your own with exclude: ["worldMap"]: those behave like world windows.
Settings schema#
A plugin declares its settings as a list of fields:
| Field | Meaning |
|---|---|
key | camelCase name the plugin reads |
label, description, group | What the editor form shows |
type | string, number (min/max), boolean, select (options), key (a key code), asset (one of the plugin's files), color (#hex), or list (records with item fields) |
default | Must itself be valid. A list's default is its starting rows. |
The form on the Settings tab is built from this schema. A saved value that is no longer valid falls back to the default, so the plugin never receives a missing setting.
Gotchas#
- "needs the … capability" in the browser console. Grant that capability on the Plugins page, then turn the plugin off and on again.
- Settings don't change in game. They reach players at login. Ask testers to log in again.
- A dock button opens nothing. That window's system is off in this world, or the panel is switched off in UI settings.
- Hosted projects need engine 0.7.1 or newer on the game server. Older servers don't send project client plugins to players.
- Project client plugins always run sandboxed (QuickJS), even if the sandbox flags are off.
getHudLayout()andonHudLayoutChangeneed plugin API level 3. Set Made for plugin API to 3 on a plugin that uses them; an engine older than that doesn't have them.hostPanels,getPanelHost,onPanelHostChange,closePaneland the minimap'sfollow/viewTilesneed plugin API level 4. Checktypeof ctx.hostPanels === "function"and fall back toopenPanelon an older engine.hostPanelsreturns false. Another plugin already hosts the game's windows: only one can.- A window looks squeezed in the frame. Raise
minWidth(wider layout, scaled down) or make the frame bigger while a window is open. A phone grows when an app opens. - An NPC window opened in the frame. It shouldn't: tell us which one. Meanwhile add its id to
exclude.