mod.json
Every key a mod.json may hold, and the rules between them.
A minimal mod.json #
{
"$schema": "https://playaconline.com/schemas/mod.schema.json",
"schema": 1,
"api": 1,
"id": "yourname.tea-stall",
"name": "Tea Stall",
"version": "1.0.0",
"authors": [
"Your Name"
],
"scope": "client",
"assets_original": true
}Keys #
| Key | Value |
|---|---|
$schema (optional) | string |
schema | always 1 |
api | integer, 1 to 1 |
id | string, at most 81, matching ^[a-z0-9][a-z0-9-]{0,31}\.[a-z0-9][a-z0-9-]{0,47}$ |
name | string, matching ^\s*\S(?:[\s\S]{0,58}\S)?\s*$ |
version | string, matching ^(0|[1-9][0-9]{0,8})\.(0|[1-9][0-9]{0,8})\.(0|[1-9][0-9]{0,8})$ |
authors | array, 1 to 8 |
description (optional) | string, at most 500 |
tags (optional) | array, at most 5 |
scope | one of "client", "world" |
content (optional) | object |
scripts (optional) | object |
permissions (optional) | array |
exports (optional) | object |
assets_original | always true |
renames (optional) | object |
depends (optional) | object |
optional_depends (optional) | object |
conflicts (optional) | object |
data_version (optional) | integer, 1 to 1000000 |
settings (optional) | array, at most 16 |
$schemasince 1 optional #
Optional. The JSON Schema an editor checks mod.json against, for autocomplete and errors as you type. The game ignores it.
schemasince 1 required #
The manifest format. Always 1.
apisince 1 required #
The mod API level the mod is made for. The game checks a mod by the rules of its own level. It runs an older level through shims while that level is supported. A level only changes for a breaking change; new names arrive as a minor version of the level (API 1.1), and a mod made for 1.0 still says 1. Use the newest level.
idsince 1 required #
author.mod-name, in lowercase letters, digits and dashes, with one dot. The author parts playaconline, official, admin and example are reserved for the site's own mods in the mod list. The mod list also refuses an author part that passes for one of them (official-, examples, playaconline-official).
namesince 1 required #
The name players see, 1 to 60 characters after trimming spaces. The mod list also refuses a name with a line break, another control character or a hidden text-direction character.
versionsince 1 required #
x.y.z, each part 1 to 9 digits with no leading zero. Every upload needs a version number this mod has not used yet. The number of a refused upload can be used again.
authorssince 1 required #
1 to 8 names, each 1 to 40 characters. The mod list also refuses a name with a line break, another control character or a hidden text-direction character.
descriptionsince 1 optional #
Optional text of at most 500 characters. null is refused. Leave the key out instead.
tagssince 1 optional #
Optional. The mod list's filters: at most 5 different tags from a fixed list, lower case. Players filter the mod list by them. The game never reads them. Anything else is refused (manifest-tags).
scopesince 1 required #
client is a Just you mod, which only you see. world is a World mod, which changes what a visitor to your town would see. Only a World mod may hold a shop (content.shops) or a calendar file with a board notice. A friend visit needs the same World mods that count (see visit_scope) on both sides.
contentsince 1 optional #
What the mod adds, each a path inside the mod: textures, messages, shops, items, letters, calendar and talk. Anything else is refused. textures names a folder, and every other key names one file. Every text shows as written.
scriptssince 1 optional #
A Lua script and the events it listens to. events may list data_migrated only with a data_version.
permissionssince 1 optional #
The commands the mod's script may queue, each once. The game refuses any command the list leaves out. The Mods tab and the moderators' review show what the list lets the mod do. take_item and take_bells let the mod ask the player for items or Bells. The game itself shows the question with the true item and amount, and nothing is taken unless the player says yes. save lets the mod save the town where the player could save at Gyroid. play_sound lets the mod play the game's own sound effects, heard only by its own player. set_weather sets the town's weather for the day, and set_shop_goods and set_shop_open change a shop for the day. The three need scope world. set_hat and set_shirt change only how the player's hat or shirt looks on their own screen and work in any mod. react plays one of the reactions on the player's own character and works in any mod. Needs scripts.
exportssince 1 optional #
A library's remote functions by name, each with a one-line description. These are what other mods may remote.call. At most 32 names, each 1 to 32 of a-z 0-9 _. Each description is 1 to 120 characters on one line. When exports is declared, the game lets remote.add offer only these names. The Mod log says when a listed name was never offered. Needs scripts.
assets_originalsince 1 required #
Must be true. It is your promise that the mod holds only work its authors made, never files taken from the game.
renamessince 1 optional #
Maps an old full item id of this mod to the full id of an item in this mod's items file. At most 64. Needs content.items. Each rename runs once per save, and mod-items.json records it. A renamed item already in a house therefore keeps working.
dependssince 1 optional #
Mods this one needs, as mod id to version range. A range is "*", or up to 4 comparisons (>= <= > < = and a version) split by one space. At most 16. This mod loads after them. It does not load when one is missing, off, out of range or not loading. The game checks again when it starts: a mod whose dependency is not loaded before it, in range, is not loaded at all.
optional_dependssince 1 optional #
Mods this one can use but does not need, as mod id to version range. Ranges are written as in depends. At most 16. This mod always loads. An optional dependency is present when it is installed, switched on, loading and inside the range. A present one loads before this mod. One that is missing, off, not loading or outside the range is absent, and nothing waits for it. A script asks with remote.version(id). remote.call to an absent one returns nil, a message and a code. It is not an error. A mod id may be in only one of depends, optional_depends and conflicts.
conflictssince 1 optional #
Mods this one cannot run with, as mod id to version range. At most 16. A mod id may be in only one of depends, optional_depends and conflicts. This mod stays off while a matching one is on.
data_versionsince 1 optional #
A whole number 1 to 1000000 for the shape of what the scripts save. When it changes, the data_migrated event runs once per town. Listing data_migrated in scripts.events needs it.
settingssince 1 optional #
At most 16 settings the player sets on the Mods tab and scripts read with settings.get. The types are bool, number (whole, with min and max), choice (2 to 16 choices) and text (max_length 1 to 200). A setting may say "scope". "world" is the default: the value is part of the town, a friend visit compares it, and a visitor lent the mod runs the host's value. "client" is the player's own: it is never compared or sent, and each player keeps theirs on a visit. Use client for a choice that only changes what its own player sees or hears.
Rules #
- Reserved for planned features, refused even when null:
game,save. - A key the game does not know is refused. The message names the closest key:
mod.json: unknown key "permisions" (did you mean "permissions"?). - content.shops requires scope world.
- Every shop takes the same block, and each field means the same on every shop. The shop table (files.shops.shop_table) lists the fields each shop has, and it is read from the game itself. A field a shop does not have is left out, not refused: the rest of the block applies and the mod's row in the Mods tab names the shop and the field (code shop-field-ignored). Nook's store and Able Sisters have no lines, because their keepers speak only the disc's own words.
- A key the game does not know is refused. This applies at the top of mod.json, at the top of the shops, items, letters, calendar and talk files, and in each of their entries (a shop block, a good, a "when" and its hours, an item, a letter, a calendar day, a talk pool). The messages file is the exception, because its keys are the lines. The message is <file>: unknown key "<key>", followed by (did you mean "<known>"?) when a known key is close. $schema is known wherever a file may carry it. Keys are case-sensitive.
- Duplicate keys and \u0000 are refused in every JSON file.
- A mod may hold only these file types (case-insensitive).:
.json .lua .dds .png .txt .md - Files a mod repository holds for people, not for the game. playac-mod pack leaves them out, and the game and the mod list ignore them in any ZIP: they are dropped before any other rule, never unpacked or stored, and counted toward no limit. So a ZIP made by hand of a whole mod repository installs. They are any part of a path that starts with a dot (.git, .github, .gitignore, .vscode, .playac, .DS_Store), any part named in any_parts, and at the top of the mod (inside the one top folder, when the ZIP has one) a file named in top_files, a file whose name before its extension is in top_stems (LICENSE, LICENSE.md, license.txt), and everything in a folder named in top_folders (media/, for the README's pictures, film and media.json). Names match in any letter case.
- All mods share 4 ms of Lua time a frame. Past it, every game event without an answer (day_started, item_picked_up, scene_entered and the others) waits for the next frame. Events wait in order for each mod, at most 64 at a time, and one past that is dropped. villager_talked is skipped for the rest of that frame, so the villager says their own greeting. A mod with events still waiting is not asked for a villager_talked line until they have run. The next mod is asked instead. Each mod therefore sees its own events in the order they happened. A remote.call into a mod is not one of its events. It runs at once, inside the caller's event. command_finished and question_answered wait too, but are never dropped or skipped. villager_answered runs at once: the player is waiting on it. A command queued by a command_finished handler is applied at the next frame boundary, not the one that delivered the result. data_migrated runs as a town loads, outside the limit.
- scripts.events may list data_migrated only with a data_version.
- A mod id may be in only one of depends, optional_depends and conflicts. None of them may name the mod itself.
- A World mod that declares world settings adds a hash of their values to its entry in the list of mods a friend visit compares. The entry gains +<sha256 of "name=value\n" per world setting, sorted>. The visit's list of mods carries that hash and the values too, so two towns on one mod with different settings are told "same mod, different settings". A setting whose scope is client is not in the hash, and its value is never in the list. A mod with only client settings adds no hash. A mod with no client setting hashes as it did before scopes existed.
- Which mods a friend visit compares. A Just you mod never counts. A World mod counts if its content has textures, shops or items (visit_scope_content), if its permissions name set_shop_goods or set_shop_open (they change a shop), or if its permissions are not a list of strings. Every other World mod does not count. That covers a mod with only lines, letters, calendar days or talk pools. No command makes a mod count. send_letter, give_item, take_item, take_bells, save and set_weather are refused on a visit, show_line, ask and play_sound reach only their own player, set_hat and set_shirt change only how the player's hat or shirt looks on their own screen, and react moves only the player's own character. A visitor sees the host's weather through the game itself, with or without the mod that set it. Only mods that count must match between the two towns. An optional dependency is a mod like any other here. When it is a World mod that counts, it is in the list, and installing it changes what a visit compares.:
send_letter give_item show_line ask take_item take_bells save set_weather play_sound set_hat set_shirt react - The content keys that make a World mod count for visits, whatever its permissions. They are what a visitor must draw or meet in the town.:
textures shops items - What needs scope world, because it changes the town a visitor sees: a shops file (content.shops), a calendar file with a board notice, and the permissions set_weather, set_shop_goods and set_shop_open. Everything else may be client (only you see it) or world.:
shops board set_weather set_shop_goods set_shop_open - When two mods change the same thing, the last in load order wins it whole. For a shop that is per shop id: the later mod's blocks are that shop, and the earlier mod's change to it is not used. Two mods that change different shops both apply. The earlier mod's row in the Mods tab names the shop and the mod that has it. Inside the mod that has a shop, all its blocks for it apply. For a texture, the kind of file comes first. A file for one exact palette (tex1_..._<tlut>_<fmt>) beats any mod's every-palette file (tex1_..._$_<fmt>) for the same texture, whatever the order. Between two files of the same kind, the later mod's is drawn. A mod's texture of either kind beats the HD pack's.:
textures shops - A villager's talk has five places for a mod's words: before, hello, topic, after and conversation. Each takes one line per talk, and every line names its place. Every mod's villager_talked handler runs, in load order, and the first line a handler returns for a place takes it. A conversation takes the whole talk, so it needs every place free; once one is taken, the event stops. Lines a script did not take a place with come from talk files, which are not first-wins: every mod's fitting pools of that place are put together and one line is picked from all of them, fresh on every talk.:
villager_talked - Developer mode reloads these while you play, with no restart: the content files named here, any .lua script ("scripts") and the files under content.textures. Developer mode means a mod loaded from a folder or from playac-mod dev. Each value is a content key, or "scripts".:
messages shops talk letters calendar items scripts textures - Developer mode loads a change to these only when the game restarts: mod.json and the content files named here. mod.json is read once at start, and so is a file added or removed. Each value is "mod.json" or a content key.:
mod.json - Visiting with the host's mods. When every World mod of the host that counts is a reviewed version from the mod list, a visitor can load them for that visit only, after agreeing. They run with the host's world settings. Each mod's world values travel with the visit, are checked against what its mod.json allows, and are never kept on the visitor's game. A text setting the host changed from its default must pass the site's word checks (no rude words, contact details or risky phrases). If it does not, the visit is refused instead of lent. A client setting is the visitor's own. It keeps the value the visitor set on their installed copy of the mod, and it is the default when the visitor does not have the mod. Nothing is installed. The game restarts with the lent mods, and their scripts start with an empty store that is never saved. A lent mod acts only in the host's town. At home, in the restart before the trip and the one after it, its shop, Nook goods, board notices, items, renames and commands do nothing. It therefore never changes the visitor's own town or save. A mod installed from a file cannot be lent. Nothing is lent while mods are switched off for everyone. A set that would not load whole on the visitor's game, in the host's order, with the visitor's own Just you mods and under the same limits, is refused before the restart.
- The City's own mod set is a short list chosen by the site and changed only with a release. A City mod may hold only textures and messages. It has no shops, no scripts and no permissions.
- A calendar file with a board notice requires scope world. The board is the town's, and a visitor reads it.
- A calendar day's "letter" goes out once per day per town. It goes out only in the player's own town, not on a visit and not in The City. It counts against the mod's daily send_letter limit. A refusal is written to the Mod log, never to a script.
- The characters the game's font draws in a mod's lines (messages, talk lines, shop greetings, show_line and ask). Every printable ASCII character is drawn, except $ * ^ | \ which are each drawn as ?. The characters # + / ; are drawn by the font's own signs. [ ] { } are drawn as ( ), ` as ' and ~ as the villagers' wavy tilde. The letters and signs listed here are drawn too. Curly quotes, dashes, the ellipsis and a no-break space become their ASCII spelling. Any other character is drawn as ?. Letters and board notices take plain ASCII only. values holds the extra characters, from the font's own table.:
¿ Ä À Á Â Ã Å Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ù Ú Û Ü ß Þ à á â ã ä å ç è é ê ë ì í î ï · ð ñ ò ó ô õ ö ù ú û ü ý ÿ þ Ý § ª º µ ³ ² ¹ Æ æ « » × ÷ - permissions requires scripts, because only a script can use a command.
- exports requires scripts, because only a script offers functions.
- Nothing of a mod runs outside the player's own game. At the title screen, at player select and in the intro no event fires, no timer fires, no command is applied, no calendar letter goes out and no town data is loaded, so data_migrated does not run there either. The title screen plays a demo in the player's own save with the clock set to a date in 2001. A script never sees that date. Whatever was waiting keeps waiting and carries on when play starts: a timer that came due fires then, and a command queued before a save and quit is applied then. The one part of a script that runs outside the game is its main chunk, at start, before a town loads.
- An event handler never changes the game. Each cmd.* call queues a command. The game applies the queue at one point in each frame: at the end of the game's update, after the world moves and before that frame is drawn. It applies commands only while the player is free, which means not in a talk, menu, cutscene, door or scene change. A sound (play_sound) is the one exception: it changes nothing, so it plays at the next point in a frame wherever the player is, and never waits behind a line. A command's result comes back as a command_finished event to the mod that queued it.
- Every command but set_hat, set_shirt and react is refused in The City. On a visit to a friend's town, send_letter, give_item, take_item, take_bells, save and set_weather are refused, because only the town owner's game changes a town, its weather or a player's save. show_line, ask, play_sound, set_hat, set_shirt and react still run, for the visitor only. The last three change only the player's own character and nothing saved.
- A letter's present and a given item follow the shop's item rules: no money, turnips, tickets, grab bags, fossils or reserve ids. give_item also takes this mod's own new item by its full id. Full pockets refuse a mod item, because a letter cannot carry its identity. A plain item comes by letter instead.
- In Lua an id is always a number, never a hex string. That holds for an item, a villager and a scene. JSON data files write an item as a string, "0x2800". The commands take an item as a number, as "0x2800", or as the mod's own "author.mod:thing".
- A setting is world or client. A world setting is part of the town. A friend visit compares it, and a visitor lent the mod runs the host's value. A client setting is the player's own. It is never compared and never sent, and on a visit each player runs their own value. A client setting may decide only what its own player sees or hears: a line, a question, a display choice. It may not decide what the town gets or gives up. The game checks this where it can. In an event that read a client setting with settings.get, a command that changes the town is refused with the code command-client-setting. Those commands are the values of this rule. The check covers one event. A value kept in a variable, in store or in a timer's data and used in a later event is not caught, and neither is a value passed through remote.call. timer.after is not refused after a client setting was read, because a timer that only shows its player a line later is a proper use. Those cases are the modder's to avoid. Their failure is silent: the host's town gets what the host's value says, while a visitor's copy of the mod runs the visitor's value and can show a line that does not match.:
send_letter give_item take_item take_bells set_weather - Load order with optional dependencies. A present optional dependency loads before the mod that names it, exactly as a needed one does. An absent one changes nothing. Present means installed, switched on, loading and inside the range. A mod whose optional dependency is outside the range still loads, and that dependency counts as absent for it.
- A cycle through an optional dependency never stops a mod from loading. When every mod left to place waits for another, the earliest of them in the player's order whose needed dependencies are all placed loads next. It loads before the optional dependencies it was waiting for, and they load after it. Such a dependency is still present. remote.version and remote.call work in events. Only the promise that it loads first is dropped for that one mod, so its main chunk must not count on the dependency. A cycle made only of needed dependencies is still refused.