mugon.net docs
CLI

Project config

The mugon.toml of a project and the global CLI config.

mugon.toml

Every project has a mugon.toml in its root. mugon init creates it; dev, publish and run read it.

id = "my-game"
version = "0.1.0"
js-sdk-version = "0.1.0"

# Optional, defaults shown
distribution-dir = "dist"
source-dir = "src"
watch-paths = ["src"]

[[command]]
name = "install"
command = "npm install"

[[command]]
name = "build"
command = "npm run build"
FieldRequiredDefaultDescription
idYesThe project ID. Must match the game name on mugon.net.
versionYesThe semver version that mugon publish publishes. Each publish needs a version that doesn't exist yet.
js-sdk-versionYesThe version of @mugon/sdk your game bundles. Its major is recorded with the published version and has to match what the game really bundles, see SDK versions.
distribution-dirNodistThe folder with the built game. Everything in it is uploaded, and it needs an index.html at its root.
source-dirNosrcYour sources. Default for watch-paths.
watch-pathsNo[source-dir]Files and folders that trigger a rebuild in mugon dev.
[[setting]]NononeSettings the game initiator can adjust before the game starts, see Settings.
settings-valid-whenNoExpression that must be true before the game can start, see Gating with expressions.

Command entries

[[command]] entries are matched by name, scope and os. Several entries can share a name: the CLI picks the one that fits the scope and your operating system.

FieldRequiredDefaultDescription
nameYesFor example build or install. build is what dev and publish run.
commandYesThe shell command.
scopeNodefaultA context for the command. mugon dev prefers the dev scope, mugon publish prefers default, mugon run uses default unless you pass --scope.
osNoindependentindependent, linux, darwin or windows.

A common use of scopes is a fast dev build and a slow, fully optimised default build. The bevy template does exactly that.

Settings

[[setting]] entries declare the options the initiator of a game can adjust before it starts. The declarations are stored with the version that mugon publish uploads, and the chosen values reach the game through the SDK: ctx.settings, or the typed getBoolean, getNumber, getString and getStrings helpers, see Mugon.start.

Settings are immutable once a version is published: changing a declaration means publishing a new version. They render in declaration order, and mugon dev shows the same settings in a panel next to the game so you can try them locally.

[[setting]]
key = "friendly-fire"
label = "Friendly fire"
tab = "Gameplay"
type = "boolean"
default = false

[[setting]]
key = "round-time"
label = "Round time (s)"
tab = "Gameplay"
type = "number"
min = 30
max = 600
step = 30
default = 120
ui = "slider"

[[setting]]
key = "map"
type = "select"
options = ["desert", "forest"]
default = "desert"

[[setting]]
key = "modifiers"
type = "select"
multiple = true
options = [
    { value = "fast", label = "Fast rounds" },
    { value = "low_gravity", label = "Low gravity" },
]
default = ["fast"]

[[setting]]
key = "server.name"
type = "text"
default = "My server"
max-length = 32
FieldRequiredDefaultDescription
keyYesThe key the game reads the value by. Lowercase alphanumeric segments separated by ., _ or -. The mugon. namespace is reserved for the SDK's own keys.
typeYesboolean, number, select or text.
defaultYesThe value the setting starts at. Must match type; for select either a single string or a list of strings.
labelNokeyDisplay name in the settings UI.
descriptionNoLonger explanation shown next to the input.
tabNoGeneralGroups settings into tabs in the settings UI.
uiNoThe input to render. boolean: switch, checkbox. number: slider, number-input. select: dropdown, segmented-control, radio-cards. text: text-input, textarea. Omit it to let the UI pick.
min, maxnumber onlyBounds of the allowed range. Both are required for a number setting.
stepNo1Increment of a number setting. The default must be reachable from min in whole steps.
optionsselect onlyThe choices, either bare strings (label = value) or { value = "...", label = "..." } tables.
multipleNofalseWhether a select setting takes more than one value.
max-lengthNo1024Maximum length of a text setting's value.
enabled-whenNoExpression that must be true for the setting to be editable, see below.

mugon publish checks the declarations before uploading anything and fails with the offending key if a default doesn't match its type, a key is duplicated, or a number setting lacks bounds.

Presetting values from the URL

mugon dev and mugon.net read starting values for settings from query parameters prefixed with s., so a combination can be bookmarked or shared:

http://localhost:5173/?s.friendly-fire=true&s.round-time=180&s.map=forest
https://mugon.net/play?g=my-game&s.modifiers=fast,low_gravity
TypeAcceptedNotes
booleantrue, false, 1, 0Case insensitive.
numberAny numberClamped into [min, max] and snapped to the nearest step.
select?s.key=a&s.key=b or ?s.key=a,bEvery value must be a declared option, otherwise the parameter is ignored. A single-choice select takes one value.
textAny stringTruncated to max-length.

A parameter that carries an invalid value for its type is reported on the console and that setting stays at its default, so one stale parameter in a shared link can't make a game unstartable. The values are only a starting point; the initiator can still change them. A player that joins an existing game reads the parameters too, but they are never sent: a joining player always plays with the values the host started with.

Gating with expressions

Two fields take an expression that has to evaluate to a boolean:

FieldWhereMeaning
enabled-whenon a [[setting]]The initiator may change that setting only while the expression is true.
settings-valid-whentop levelThe game may only start while the expression is true.
settings-valid-when = 'settings["min-players"] < settings["max-players"]'

[[setting]]
key = "bots"
type = "boolean"
default = false

[[setting]]
key = "bot-count"
label = "Number of bots"
type = "number"
min = 1
max = 8
default = 4
enabled-when = 'settings["bots"]'

Expressions are a restricted subset of CEL:

  • Reference a setting as settings["<key>"]. That is the only variable in scope, and the key must be a string literal naming a setting this version declares.
  • Operators: && || !, == !=, < <= > >=, + - * /, in, and cond ? a : b.
  • One function: size(x), the length of a multi-select or a string.
  • Nothing else: no macros, type conversions, string methods or list literals.
  • A setting's own enabled-when can't reference that setting.
!settings["friendly-fire"]
settings["round-time"] >= 60 && settings["round-time"] <= 600
"fast" in settings["modifiers"]
size(settings["modifiers"]) > 0

Things worth knowing:

  • Every number setting is a double. Comparisons accept plain integers (settings["round-time"] >= 60), but arithmetic needs a decimal point (settings["round-time"] + 1.0).
  • Comparing different types is quietly false. settings["round-time"] == "hello" is legal and never true; publishing rejects the obvious cases.
  • A disabled setting keeps its value. Only its input locks, so a game should check the gating setting itself before reading a gated one.
  • Gating is enforced by mugon.net, not by your game. The game never evaluates expressions. It only receives the final values.

Expressions are validated when you publish, against the settings that same version declares. A typo, an undeclared key, a non-boolean result or a type mismatch fails mugon publish with an explanation. mugon dev evaluates them straight from mugon.toml and reports problems in the browser console instead. At play time a failing evaluation leaves the setting editable and the game startable.

Global config

~/.mugon/config.toml is written by mugon login and mugon logout; you rarely need to edit it.

[credentials]
my-game = "<api key>"

# Optional: use another API, for example staging
mugon-net-api-url-override = "https://backend.stage.mugon.net/api/v1"
FieldDescription
credentialsProject ID to API key.
mugon-net-api-url-overrideReplaces the default API address https://backend.mugon.net/api/v1.

The MUGON_PROJECT_API_KEY environment variable supplies an API key without storing it, and takes precedence over the stored one.

On this page