v1.3
API 1

Make a plugin

A folder, a few lines of Lua, and your idea runs in the game. Start from the template, read what the api can do, test it on your PC, then share it.

01Overview

A Mhodume plugin is a folder holding a plugin.json and a main.lua. The mod loads it in game and gives it api: read where the player is and how fast they go, react to keys and to level changes, draw lines, boxes and text on top of the game, keep files, and even redraw the mod's own text in another font.

  • Training only. Plugins run where the mod runs: in Training, never in Compete, never in online play.
  • A sandbox. A plugin can't open files outside its folder, run programs, reach the network, or call the game engine directly. On VHOLUME a wrong engine call doesn't fail, it crashes the game: the api only offers what has been proved safe.
  • Lua 5.4. The language UE4SS runs.
  • Errors are contained. A plugin that keeps failing is switched off; the mod and the other plugins go on.

What a plugin can and can't do

A plugin can read what the game and the mod show, and draw on top of the game. It can't change the mod's data or behaviour. Keep that split in mind: changing how a text looks on screen is not the same as changing the thing it describes.

A PLUGIN CANA PLUGIN CAN'T
Draw lines, boxes and text on top of the gameChange the game: move the player, its speed, the physics, VHOLUME's own HUD and menus
Read the player's position, speed and view, and the level's nameChange the mod's data: sections, checkpoints, profiles, presets, crosshair settings, Training
React to keys, level changes, its settings changing, clicks on its buttonsRename the mod's sections or anything else it stores. It can only change how a text is drawn.
Change how the mod's own in-game texts are drawn (their font, even the string drawn)Change the Launcher or the overlay: menus, section names, pages other than its own
Keep files in its own folderRead other files, other plugins' data, or the network
Have a page in the Launcher and the overlay: settings, live values, buttonsRun code in the Launcher or the overlay
Show a message in the middle of the screenUse UE4SS, or run in Compete or online

02Quick start

  1. Download the template (Top Speed: your best speed on the current map, under the crosshair). Every line of its main.lua is commented, and this guide is inside as GUIDE.txt, to read offline.
  2. Unzip it into %LOCALAPPDATA%\Mhodume\plugins\top-speed\. The folder's name is the plugin's id.
  3. Create %LOCALAPPDATA%\Mhodume\plugins.json:
    { "top-speed": { "enabled": true, "stamp": 1 } }
  4. Start VHOLUME in Training: run fast, your top speed shows under the crosshair. K resets it.
  5. Rename the folder and the id in plugin.json, and make it yours.

The smallest plugin there is:

-- main.lua
api.onDraw(function(w, h)
    api.draw.text("HELLO", 40, 40, 20, { 1, 0.29, 0.12, 1 })
end)

03The folder

my-plugin/
  plugin.json     required: who the plugin is
  main.lua        required: what it does
  settings.json   optional: the settings the Launcher shows
  README.md       optional: say what it does and its settings
  any data        read with api.load (.txt .json .csv .md, pictures)

plugin.json

{
  "id": "my-plugin",
  "name": "My Plugin",
  "version": "1.0.0",
  "api": 1,
  "author": "you",
  "description": "One line: what a player gets."
}
FIELDRULES
id2 to 40 of a-z 0-9 - _, starting with a letter or digit. Must be the folder's name. It is yours once published: nobody else can upload under it.
nameWhat players see.
versionmajor.minor.patch, e.g. 1.2.0. Each upload must be higher than the last, and match the version typed in the upload form.
apiThe api version you wrote for. Today: 1. A mod older than your api refuses to load the plugin rather than run it half-working.
author, descriptionFree text, for people reading the folder.

04How it runs

  1. Loading. main.lua runs once, at the top of a game frame. That's where you register your callbacks (api.onTick, api.onDraw, api.on) and read your settings and files.
  2. Each frame, in this order: your onTick functions (read the game, react to keys; nothing can be drawn yet), then the mod draws (crosshair, speed, panels…), then your onDraw functions, on top of everything.
  3. Events arrive at the top of a frame: map when a level is entered, settings when the player changes your settings.
  4. Switching off in plugins.json stops calling your functions at once; switching on again resumes them without loading the code again. A new stamp loads your files again from scratch.
When it fails. An error in one of your functions is caught and written to the log once (the mod's, and your plugin's own plugin.log). After 60 failures in a row (about a second) the plugin is switched off until the player presses F6 or reloads it. An error while loading main.lua stops the plugin from loading; the reason is in the log and in plugins\status.txt.

The life of a plugin, in order

  1. Off in plugins.json, or not there: nothing of it runs.
  2. Turned on: at the top of the next frame of a level, main.lua runs once in a fresh sandbox. Plugins load in the order of their ids (a, b, c…). Register your callbacks here: an event that happens before you register for it is not sent again.
  3. First frames: as soon as the level's name is known, every plugin gets map (with old nil the first time). Then, each frame: onTick, the mod draws, onDraw.
  4. In menus and loading screens there is no HUD to draw on, so no callback is called. Your Lua stays as it was: the next level picks up where you left.
  5. Turned off: your callbacks stop being called, your state is kept, and the mod draws its own texts again. Turned on again: they resume, main.lua doesn't run again.
  6. A new stamp (or an update installed by the Launcher): everything of yours is dropped (callbacks, keys, live values, the text you took over) and main.lua runs again from scratch.
  7. Errors: 60 in a row switch the plugin off until F6 in game or a new stamp. An error in main.lua itself means it isn't loaded until a new stamp or the next game.
  8. The game closes: everything ends. Next game, it all starts over at step 2, and your log becomes plugin-1.log.

05The api

Everything below is a field of the global api. Coordinates are screen pixels, (0, 0) top-left. A colour is a table { r, g, b, a }, each from 0 to 1. Speeds and positions are in the game's units (centimetres, and centimetres per second).

Basics

CALLWHAT IT DOES
api.idYour plugin's id.
api.versionThe api version of the mod running you (1).
api.log(...)Writes a line to the mod's log, tagged [your-id]. print does the same.
api.notice(text, seconds)Shows a message in the middle of the screen, 3 seconds by default. One message at a time, shared with the mod.
api.time()Seconds, with decimals. Use differences, not the value itself.
api.frame()The frame counter.
api.screen()The screen's width and height, in pixels.
api.map()The current level's name, e.g. Gold_racetrack, or nil.
api.show(id, value)Shows a value live on your plugin's page, on the value line of settings.json with this id. Text up to 200 characters; nil clears it.

Callbacks & events

CALLWHAT IT DOES
api.onTick(function(w, h) … end)Called every frame, before anything is drawn. Read the game and keys here.
api.onDraw(function(w, h) … end)Called every frame after the mod has drawn. The only place you can draw.
api.onText(function(text, element) … end)A text the mod shows appeared or changed (text nil: it's gone). See reading the mod's text.
api.on("map", function(new, old) … end)A level was entered, the first one too (old is nil then).
api.on("settings", function() … end)Your settings changed: read them again.
api.on("button", function(id) … end)One of your button settings was clicked in the Launcher or the overlay; id says which.

You can register several functions of each kind; they run in the order registered.

What happens in a run

Mhodume tells you what its sections and the level's timer do, at the top of the next frame. Each function gets a table of its own (numbers, text, true/false): read it, keep what you need, change it if you like - no other plugin sees your changes, and nothing you do changes Mhodume's times. Times are in seconds.

EVENTWHENTHE TABLE
run_startThe first section is entered and no run is going. map, sections (how many)
section_startA section is entered. map, section (1, 2…), sections
section_completeA section is closed. map, section, sections, time, best (the best before this one, absent the first time), delta (time - best), isBest
run_completeEvery section closed, in order. map, sections, time, best, delta, isBest
lap_abandonedA section left open: the level changed, you were moved. map, reason
drill_backDrilling put you back at the start of a section. map, section, why ("reset" or "finished")
timer_startThe level's own timer starts (your first move). map
timer_resetThe level's own timer is back to 0 (T). map

These are Mhodume's sections, the ones placed on the Sections page - not the game's own checkpoints.

A whole example: each section's time, against your best, for three seconds.

local shown, untilT = nil, 0

api.on("section_complete", function(s)
    local line = string.format("S%d  %.3f", s.section, s.time)
    if s.delta then line = line .. string.format("  %+.3f", s.delta) end
    shown, untilT = line, api.time() + 3
end)
api.on("lap_abandoned", function() shown = nil end)

api.onDraw(function(w, h)
    if shown and api.time() < untilT then
        api.draw.text(shown, w / 2 - 80, h * 0.7, 22, { 1, 1, 1, 1 })
    end
end)

Your records

Your best time on each level, and your times at the game's checkpoints in it, taken from the ghosts the game keeps of your runs (one per level and category: your best). The Launcher reads them while it is open and the mod gives them to you. Downloaded ghosts are not yours and are left out. Times are in seconds; a checkpoint's is from the start of the run.

CALLWHAT IT DOES
api.record(map, category)Your record on a level: this one when map is nil, in "Normal" unless you name another category (or the only one there is). Names in any case. nil when there's no finished ghost.
api.records()Every record, every level and category, as a list.

A record is a table of its own:

FIELDWHAT IT IS
map, categoryThe level, e.g. Gold_racetrack, and the category, e.g. Normal.
timeThe whole run.
checkpointsA list, in order: { id = "CP_…", time = … }, the game's own checkpoints (not Mhodume's sections). Empty on a level without any.
hops, perfectHopsWhen the game counted them, else nil.
playerThe name on the ghost.

For example, your record on this level as you arrive:

api.on("map", function(map)
    local r = api.record()
    if r then
        api.notice(string.format("Your record: %.3f (%d checkpoints)", r.time, #r.checkpoints))
    end
end)

A new best shows up a few seconds after the game saves its ghost, when the Launcher is open.

Settings

CALLWHAT IT DOES
api.setting(name, default)One setting, or default when it isn't set.
api.settings()All of them, as a table.

Settings come from what the player set in the Launcher (or by hand in plugins.json): numbers, text, true/false, lists. Always give a default; declare them in settings.json, below, so the Launcher can show them.

local size = tonumber(api.setting("size", 14)) or 14
api.on("settings", function() size = tonumber(api.setting("size", 14)) or 14 end)

Settings players can change: settings.json

Put a settings.json beside your main.lua and the Launcher shows a Settings button for your plugin, with a control for each setting. What the player sets reaches you through api.setting, and a settings event tells you when it changes.

{
  "settings": [
    { "id": "size",  "type": "number", "label": "Text size", "default": 14, "min": 8, "max": 40, "step": 1 },
    { "id": "color", "type": "color",  "label": "Colour",    "default": [1, 0.29, 0.12, 1] },
    { "id": "where", "type": "choice", "label": "Position",  "default": "top",
      "options": [ { "value": "top", "label": "Top" }, { "value": "bottom", "label": "Bottom" } ] },
    { "id": "font",  "type": "font",   "label": "Font",      "default": "font.txt" }
  ]
}

Every setting has an id (a letter, then letters, digits or _), a type, a label, a default, and may have a help line shown under the label.

TYPECONTROLVALUE YOU GETEXTRA FIELDS
togglea check boxtrue / false
numbera slidera numbermin, max, step
texta text boxtext
keya button: the player clicks it and presses the key (or a middle or side mouse button)the key's name, for api.key / api.pressed
choicea drop-down listthe chosen valueoptions: values, or { "value", "label" }
multicheck boxesa list of the chosen valuesoptions, as above
colora colour box{ r, g, b, a }, 0 to 1
valuea line showing a value, livenothing: you fill it with api.show(id, …)
buttona buttonnothing: a click is a button event with this idconfirm: a question asked before
lista table, livenothing: you fill it with api.list(id, rows)columns: the headings
groupa heading that folds what follows, up to the next groupnothing (it needs no id)collapsed: true to start it folded
font“Choose a font…”the name of a font file in your folderheights: the text heights to prepare, default [14, 16, 19, 24, 30, 38]

Groups. A group line starts a section of your page with its label as a heading; the player clicks the heading to fold or unfold it. Everything after it belongs to it, up to the next group. Put rarely changed settings in a group with "collapsed": true.

{ "type": "group", "label": "On screen" },
{ "id": "size", "type": "number", "label": "Text size", "default": 14, "min": 8, "max": 40 },
{ "type": "group", "label": "Colours", "collapsed": true },
{ "id": "color", "type": "color", "label": "Colour", "default": [1, 1, 1, 1] }

The key type. Let the player choose your keys: a key setting gives you the name of the key they pressed, ready for api.pressed. When they change it, the old key stops counting against your 8 (see keys).

local key = api.setting("resetKey", "K")
api.on("settings", function() key = api.setting("resetKey", "K") end)
api.onTick(function() if api.pressed(key) then reset() end end)

The font type. The player picks any .ttf / .otf, or the .zip from fonts.google.com. The Launcher turns it into a font-<name>.txt file in your folder (every printable character as rectangles, at each height) and sets your setting to that file name. Read it with api.load and draw the rectangles with api.draw.rect: the Custom Font example has the whole reader. Ship a default font file of your own as the default, made with tools/make_plugin_font.py.

What you choose, what you don't. You choose which settings there are, their order, type, label, help line, options, default and range, and what each one does, since your Lua reads the value. The Launcher draws the window: its layout and look are the same for every plugin, and so are its own words (“Changes apply in game within a second”, “Reset to defaults”, the font control's buttons). A plugin never runs code in the Launcher: it describes its page, sends values to show, and is told about clicks.

Your plugin's page: live values and buttons

Everything in settings.json makes your plugin's page. Players find it in two places: the Launcher (Plugins → your plugin → Settings) and, while they play, the overlay's Plugins section. Besides settings, a page can hold:

  • Live values: a value line, filled from the game with api.show. The page reads them every second; when the game isn't running your plugin, it shows “—”.
  • Lists: a list line, a table you fill from the game with api.list: a history of runs, your times on each level… It scrolls past a dozen rows.
  • Buttons: a button line. A click reaches your plugin in game as a button event, within a second. Clicks made while the game was closed are not delivered later.
-- settings.json
{ "settings": [
  { "id": "best",  "type": "value",  "label": "Top speed on this map" },
  { "id": "reset", "type": "button", "label": "Reset top speed", "confirm": "Reset it?" }
] }

-- main.lua
api.onTick(function()
    local speed = api.player.speed()
    if speed and speed > best then best = speed; api.show("best", string.format("%.0f", best)) end
end)
api.on("button", function(id)
    if id == "reset" then best = 0; api.show("best", "0") end
end)

The values go through live.txt in your folder, the clicks through plugins.json: nothing of yours runs outside the game. The template, Top Speed, has both.

api.list(id, rows) fills a list: rows is a table of rows, each a table of cells (or one value for a one-column list). Up to 200 rows of 10 cells, 80 characters a cell. Give the whole list each time; api.list(id, nil) empties it. Sending the same rows again costs nothing.

-- settings.json
{ "id": "history", "type": "list", "label": "Last runs", "columns": ["Level", "Time", "vs best"] }

-- main.lua
local runs = {}
api.on("run_complete", function(r)
    table.insert(runs, 1, { r.map, string.format("%.3f", r.time),
                            r.delta and string.format("%+.3f", r.delta) or "first" })
    api.list("history", runs)
end)

Files

CALLWHAT IT DOES
api.load(name)The text of a file in your folder, or nil if there is none.
api.save(name, text)Writes a file in your folder (1 MB at most). Returns true when written.
api.json(text)Reads JSON: the value, or nil and the reason.

A name is a plain file name with an extension, like best.txt: no folders, no ... plugin.json, main.lua, settings.json, live.txt and your logs can't be written. Read files when loading or on an event, not every frame; for big data, a simple line format is much faster to read than JSON.

The player

CALLWHAT IT DOES
api.player.position()x, y, z, or nil when there is no player (menus, loading).
api.player.speed()Horizontal speed, and vertical speed apart (negative when falling), or nil.
api.player.look()pitch, yaw in degrees.

These work inside your callbacks (and while loading), and read the game once per frame however often you ask.

Keys

CALLWHAT IT DOES
api.key(name)True while the key is held.
api.pressed(name)True on the one frame the key goes down. Ask it in onTick, every frame.

Names are Unreal Engine's: A–Z, F1–F12, One–Zero, SpaceBar, LeftShift, Tab, MiddleMouseButton, ThumbMouseButton… A plugin may watch 8 keys at once; when its settings change, the count starts again, so a key the player swapped for another in a key setting stops counting. Keys are asked of the game, not bound, so they cost the mod nothing and the game still receives them: pick keys the player doesn't use for moving, and make them a setting.

Drawing

CALLWHAT IT DOES
api.draw.rect(x, y, w, h, colour)A filled box. Transparency works.
api.draw.line(x1, y1, x2, y2, colour, thickness)A line, 1 px thick by default. Lines ignore transparency (the engine draws them opaque): use boxes for anything see-through.
api.draw.text(text, x, y, height, colour)Text in the mod's line font, top-left at x, y. Letters, digits and . , : - + / %; lowercase is drawn as capitals.
api.draw.textWidth(text, height)How wide that text will be, to centre or align it.
api.onDraw(function(w, h)
    local text = "SECTION 2"
    local width = api.draw.textWidth(text, 16)
    api.draw.rect(w / 2 - width / 2 - 6, 96, width + 12, 24, { 0, 0, 0, 0.5 })
    api.draw.text(text, w / 2 - width / 2, 100, 16, { 1, 1, 1, 1 })
end)

Drawing works only inside onDraw (and a text face, below). All plugins together get 4000 drawing calls a frame; past that, the call fails for the rest of the frame.

Reading the mod's text

api.onText(fn) tells you what the mod shows, without drawing it: fn(text, element) is called at the top of the frame after a text appeared or changed, and with text nil once that element is no longer drawn. element is one of those listed below; an element drawn as several strings (the Sections panel) comes as one text, a line each. As many plugins as like can read the texts, whichever one draws them.

api.onText(function(text, element)
    if element == "splits" and text then api.log("split shown: " .. text) end
end)

A text that changes every frame, like the speed, calls you every frame: keep the function short, or use api.player.speed() instead. For a run's times, the run events give you numbers rather than text.

Replacing the mod's text

api.replace("text", face) takes over how the mod draws its own text: the speed, the badge, the panels. face has two functions; return nil from either to leave that text to the mod:

api.replace("text", {
    width = function(text, height, element)
        if element ~= "speed" then return nil end
        return #text * height * 0.6            -- how wide you'll draw it
    end,
    draw = function(text, x, y, height, colour, element)
        if element ~= "speed" then return nil end
        -- draw it with api.draw.rect / line, top-left at x, y
        return true
    end,
})

element says which text it is: speed, badge, notice, panel, splits, follow, keys. colour is the colour the mod would have used. Give the same answer to width and draw for a text: the width is what centres it. Only one plugin can replace the text; if your face fails, the mod's own lines take over. The Custom Font example does exactly this.

One plugin at a time. Only one plugin can take over the mod's text. The second one to call api.replace("text") gets the error the text is already drawn by <id> (Custom Font, for instance), even if the two would touch different elements. Plugins load in the order of their ids, so the first one wins. Turning the owner off gives the texts back to the mod but doesn't free the place: turn it off, then restart the game (or give the second plugin a new stamp). To only read the texts, use api.onText: it shares.

What each element sends

Every string the mod draws in game is sent whole, one call per string. These are real examples; use them, not guesses, to decide what your plugin matches.

ELEMENTWHERE IN GAMEWHAT text HOLDS
speedthe speed under the crosshair1235, or 1234.6 with decimals, or 1235 u/s with a suffix set in the Speed page
badgetop right, in TrainingTRAINING, or LAP NOT COUNTABLE (both can be changed in the Training page)
noticea message in the middle of the screenCHECKPOINT PLACED, FINISH OFF IN MULTIPLAYER - MOD LOADED, and what plugins send with api.notice
splitsunder the crosshair when you finish a section, or the running clock 3 +0.420 (the section's number, two spaces, the gap to your best), 3 when there's no best yet, 1:02.345 for the clock
panelthe Sections panelthe headers best, old, new (lowercase: the line font draws them as capitals), row numbers 1:, 2:…, times 12.345 or 1:02.345, and - for no time
followthe score while following a drawn runL 87%, R 92%
keysthe key pad of a drawn runW, A, S, D, JMP, CRH

Sections have numbers, not names: no text says SECTION 2. Nothing else goes through the face: not the Launcher or the overlay, not VHOLUME's own HUD, not what plugins draw with api.draw.text.

The contract

  • width(text, height, element) returns the width you will draw, in pixels, or nil to leave this text to the mod. draw(text, x, y, height, colour, element) returns true once drawn, or nil to leave it to the mod.
  • For a given text, answer both the same way. The mod centres the text with your width, then calls your draw at the position that gives. A width without a draw, or the other way round, misplaces it.
  • x, y are the top-left corner in screen pixels; height is the height of a capital letter in pixels; colour is { r, g, b, a } from 0 to 1, ready to pass to api.draw.
  • You can call api.draw.text inside draw: it always uses the mod's line font and never comes back to your face, so there is no loop to guard against.
  • An error in either function counts against your plugin, and that text is drawn by the mod for the frame.

Every call: what it returns, when it fails

“Raises” means the call stops your function with an error, which the mod catches and counts against your plugin (see the life of a plugin).

CALLRETURNSWHEN IT FAILS
api.log(...)nothingnever; past 2000 lines a game, your log stops (the mod's still gets them)
api.notice(text, s)nothingnever; replaces whatever message is showing
api.time(), api.frame()a numbernever
api.screen()width, height0, 0 before the first frame
api.map()the level's namenil in menus, or before it is known
api.record(map, category)a recordnil when there's no finished ghost of yours there
api.records()a list of recordsan empty list, never raises
api.show(id, value)nothingraises if id isn't a letter then letters, digits or _
api.list(id, rows)nothingraises for an id as above, or rows that isn't a table or nil; past 200 rows, 10 cells or 80 characters, the rest is left out
api.onTick, api.onDraw, api.onTextnothingraises if not given a function
api.on(event, fn)nothingraises for an event that isn't listed above (map, settings, button, or one of the run events)
api.setting(id, default)the value as stored, or default never, but the value can be of any type if the player edited plugins.json by hand: check it (tonumber, type)
api.load(name)the file's textnil if there is no such file; raises if name isn't a plain file name
api.save(name, text)true once written, false if the file couldn't be openedraises for a name that isn't plain, a reserved file, or more than 1 MB
api.json(text)the valuenil and the reason if the JSON is invalid
api.player.position()x, y, znil when there is no player; raises outside your callbacks and loading
api.player.speed()horizontal, verticalsame as position
api.player.look()pitch, yawsame as position
api.key(name), api.pressed(name)true or falseraises for a name that isn't letters, digits or _, or for a ninth key; a name the game doesn't know is simply never pressed
api.draw.rect/line/textnothingraises outside onDraw and a text face, for a coordinate that isn't a number, and past 4000 drawing calls in a frame
api.draw.textWidtha width in pixelsraises if height isn't a number
api.replace("text", face)nothingraises for anything but "text", a face without width and draw, or when another plugin has the text

06Limits & sandbox

LIMITVALUE
Keys watched8 per plugin at once
A list200 rows, 10 cells, 80 characters a cell
Drawing calls4000 per frame, all plugins together
Errors60 in a row, then off until F6 or a reload
A file written1 MB
The uploaded .zip5 MB, 200 files, 20 MB unzipped

Available: string, table, math, pairs, ipairs, next, select, type, tostring, tonumber, pcall, xpcall, error, assert, setmetatable, getmetatable, rawget/rawset/rawequal, unpack, print, and os.clock, os.time, os.date. Your string, table and math are your own copies.

Not available: io, the rest of os, require, load, loadfile, dofile, debug, package, coroutine, and everything of UE4SS. Only source Lua is accepted: precompiled code is refused.

Keep it light. Your functions run every frame of the game. Do the heavy work once (when loading, or on an event) and keep onTick and onDraw short. A plugin that loops for ever freezes the game: there is no way for the mod to stop it.

07Test on your PC

What players see. In the Launcher's Plugins window each plugin shows its name, version, description and state: ON, OFF, COULDN'T LOAD (an error while loading main.lua) or SWITCHED OFF AFTER ERRORS, with the reason the mod gave. Players turn plugins on and off, open their Settings, and remove them; an update keeps the files your plugin saved for itself. In game, the overlay's Plugins section shows each plugin's page.

The quick way: in the Launcher, Plugins → drop your .zip or folder on the window. It is installed and on, and its Settings, if any, are one click away. By hand, which is handy while you write it:

  1. Your folder goes in %LOCALAPPDATA%\Mhodume\plugins\<id>\.
  2. %LOCALAPPDATA%\Mhodume\plugins.json says which plugins are on, and their settings:
    {
      "my-plugin":  { "enabled": true, "stamp": 1, "settings": { "size": 18 } },
      "top-speed":  { "enabled": false }
    }
    The mod reads it a few times a second: no restart needed.
  3. Changed main.lua? Put a new value in stamp (2, 3…) and your plugin is loaded again.
  4. Your plugin's log: plugin.log, in your plugin's folder. The Launcher's Log button opens it. It holds what you api.log, and what the mod says about your plugin: loaded, refused, its errors, switched off, reloaded. The game before is kept as plugin-1.log. The same lines also go to the mod's log, %LOCALAPPDATA%\Mhodume\logs\mhodume.log, tagged [my-plugin].
  5. The status: %LOCALAPPDATA%\Mhodume\plugins\status.txt, one line per plugin: on, off, error (couldn't load) or failed (switched off after errors), with the reason.

The simulator: without the game

The simulator runs your plugin on your PC without VHOLUME, in the mod's own plugin code: the same sandbox, the same api, the same checks of what you pass it. The game is made up: a level, a player, keys, the mod's texts and run events, your records. It says what went wrong, and you can write a scenario of what happens, frame by frame, with checks of your own.

  1. Install Lua 5.4, once: winget install DEVCOM.Lua in a terminal (or any Lua 5.4).
  2. Download the simulator and unzip it next to your plugin's folder.
  3. Run lua mhodume-sim.lua ..\my-plugin from the simulator's folder.

Without a scenario it plays a short run: a level, a few seconds of moving with the speed shown, a section and a run completed, each of your key settings pressed and each button clicked. It ends with no problems, or the errors your plugin had (and exits with 1, for a script).

A scenario is a Lua file given after the folder: lua mhodume-sim.lua ..\my-plugin my-scenario.lua. In it, sim drives the made-up game:

CALLWHAT IT DOES
sim.frames(n), sim.seconds(s)Plays frames, 60 a second. The first one loads your plugin, so set the level and records before it.
sim.map(name)The level (nil: a menu). Changing it is a map event.
sim.player{ x=, y=, z=, speed=, fall=, pitch=, yaw= }Where the player is, how fast, where they look.
sim.press(key), sim.hold(key, down)A key pressed and let go, or held until you let go.
sim.event(name, data)A run event, as the mod sends it.
sim.text(element, text)A text the mod draws every frame, for api.onText (nil: no more).
sim.settings{ ... }, sim.button(id)The player changes your settings, clicks a button.
sim.records{ { map=, category=, time=, checkpoints={ {id=, time=} } } }What api.record answers.
sim.draws()What you drew on the last frame: { "text", text, x, y, height, colour }, { "rect", x, y, w, h, colour }, { "line", … }.
sim.live(), sim.logs(), sim.notice()Your live values and lists as your page reads them (history[0] is a list's row count, history[1] its first row), your log lines, the last notice.
sim.expect(ok, message)A check of yours, in the report.
sim.map("Gold_racetrack")
sim.frames(5)
sim.event("section_complete", { map = "Gold_racetrack", section = 1, sections = 2,
                                time = 14.2, best = 14.5, delta = -0.3, isBest = true })
sim.frames(2)
local drew = false
for _, d in ipairs(sim.draws()) do
    if d[1] == "text" and d[2]:find("S1") then drew = true end
end
sim.expect(drew, "the section's time on screen")

What it can't tell you: how your drawing looks (nothing is shown), and what the real game sends in a situation you didn't make up. Your plugin writes its files (plugin.log, live.txt, what you api.save) in its folder, as in game. The simulator comes with the mod's plugin code of the day: download it again when Mhodume updates.

When something goes wrong

WHAT YOU SEEWHYWHAT TO DO
COULDN'T LOADmain.lua failed as it ran: a syntax error, or a call that raised while loadingOpen the plugin's log (Log in the Launcher): the first error says where. Fix it, then give it a new stamp.
SWITCHED OFF AFTER ERRORSOne of your functions failed 60 frames in a rowOnly the first error is written, the rest are the same one: read it in the log, fix it, then F6 in game or a new stamp.
the text is already drawn by custom-fontAnother plugin took over the text firstTurn one of them off and restart the game. Two plugins can't both change the mod's text for now.
ON, but nothing happensUsually one of: not in Training; not in a level (menus draw nothing); your plugin matches a text that never appears (see what each element sends); drawing off screen; another plugin has the text; a setting you read isn't the type you expectLog what you receive, a few lines only (below), and check the screen size with api.screen().
Live values show “—”The game isn't running the plugin: closed, in a menu, or the plugin is offStart a level in Training with the plugin on.

To see what your plugin really gets without flooding the log (it runs every frame), log a little and stop:

local seen = 0
api.replace("text", {
    width = function(text, height, element)
        if seen < 20 then
            seen = seen + 1
            api.log("text", element, text)       -- the first 20 texts only
        end
        return nil                               -- leave them all to the mod
    end,
    draw = function() return nil end,
})
api.on("map", function(new) api.log("map", new) end)
api.on("settings", function() api.log("size =", tostring(api.setting("size"))) end)

08Publish

  1. Zip the contents of your folder: plugin.json and main.lua must be at the root of the .zip, not inside a sub-folder.
  2. Upload it (sign in with Discord first). Name, category, one line saying what it does, the version (the same as in plugin.json).
  3. A short wait. The team has a look at each plugin before it appears, so it can take a little while. If it isn't accepted, the reason shows on the upload page under “Your uploads”.
  4. Updates: same id, a higher version, upload again. Players get the new version once it is approved.

What is refused: anything for online play or Compete, cheating a leaderboard, executables or game files, other people's work without their permission, and fonts or pictures whose licence doesn't allow sharing (put the licence file in the .zip, as the Custom Font example does).

Files a .zip may hold: .lua .json .txt .md .csv .png .jpg .jpeg .webp.

09Examples