# Play AC Online: mod developer docs, full text Generated from the Play AC Online mod API spec and errors catalogue. Do not edit by hand. The whole of https://playaconline.com/modding/ as plain text for AI tools, plus the generated reference and errors. Short index: https://playaconline.com/llms.txt --- ## The playac-mod skill (how to make a mod, start to finish) # Making a Play AC Online mod You are helping someone make a mod for Play AC Online, a town life game that runs in the browser at playaconline.com. They do NOT have the game's source code and neither do you. Everything you need is in this file and in `reference/`: - `reference/api.md`: every mod.json key, file format, Lua function, event and limit. - `reference/errors.md`: every error message a mod can get, with its code, meaning and fix. - `reference/examples.md`: the site's complete working example mods, file by file. - `reference/items.md`: item ids each shop can stock, with names, prices and price floors. Never invent API. If something is not in `reference/api.md`, the game does not have it: say so plainly and offer what IS possible. Online, the same docs are at https://playaconline.com/modding/ (errors: https://playaconline.com/modding/errors/). ## Facts from the API spec (generated) - The game reads mod api level 1. Every mod.json says `"api": 1`; without it the mod is refused. - Level 1 (2026-11-16): The first level. Content is textures (a file may carry a readable label before its name), lines (a messages file), shops (each by its id in the shop table, from Nook's store and the flower shop to Katrina's tent, one block shape for every shop, each block applying while its when holds), new furniture on a vanilla base with pictures of its own (an items file, renames), letter templates, calendar days and villager line pools. Scripts get the events in the events list, each handed one table. They also get log, message, the game queries, a store per town with a part per player and one per browser, settings, remote calls between mods, a seeded rng and timers on the game clock. Eight commands are declared in permissions: six (cmd.send_letter, give_item, show_line, ask, take_item, take_bells) are applied at the end of a frame's update, and two (cmd.set_shop_goods, set_shop_open) are set at the call. Mods also have depends and conflicts with version ranges, and data_version with the data_migrated event. Mods can name optional_depends, and a setting can be world or client. - Versioning: A level is read for at least 12 months after the next level ships. A deprecated name keeps working for at least two more levels and at least 90 days, whichever is later. - mod.json keys: `$schema`, `schema`, `api`, `id`, `name`, `version`, `authors`, `description`, `tags`, `scope`, `content`, `scripts`, `permissions`, `exports`, `assets_original`, `renames`, `depends`, `optional_depends`, `conflicts`, `data_version`, `settings`. Reserved and refused: `game`, `save`. Any other key is refused (`unknown-key`), in mod.json, at the top of each content file and in each entry; the message names the closest known key. - `content` keys: `textures`, `messages`, `shops`, `items`, `letters`, `calendar`, `talk`. Events (20; list each one a script uses in `scripts.events`; every handler gets ONE table `e`, and a field marked `?` may be nil): - `villager_talked` e = { villager { id, name, species?, personality? } }, returns table|nil: The player starts an ordinary talk with a villager. Return where your words go in it: nil to stay quiet, a talk table { place, line, topics, ask }, or a list of talk tables, one a place. Every line names its place: a plain string is refused and logged, with nothing said. place is "before" (ahead of the hello), "hello" (instead of an everyday hello; a hello with news is kept), "topic" (instead of the topic the game picks when the player chats, if it is one of topics, small_talk when you name none, "any" for all), "after" (after the topic, before a chat ends) or "conversation" (the whole talk: no hello, no menu, no topic). line is a page of 1 to 400 bytes or a list of 1 to 8 pages. ask = { text, choices } (2 to 4 answers) goes only with "conversation": its last page asks the question, and the player's pick goes to villager_answered. Every mod's handler is called, in load order. The first line returned for a place takes it; a later one for that place is logged and not said. A conversation needs every place free and ends the event. Lines are said only when that part of the talk comes: topic and after only when the player chats. A table that is not right is logged and nothing of it is said. Special talks never reach mods. These are a first meeting, a villager moving out, one with an errand, delivery or contest going with you, a complaint, a pitfall or a bee chase, an islander, Kamakura and summer camp. No handler is called for a special talk. The villager's next ordinary talk calls it as usual, so a line a script is keeping for "the next talk" waits for that one. - `day_started` e = { year, month, day, weekday }: A new day begins in the game. It fires once per day, also when the game starts on a new day. It does not fire again when the game restarts later on a day the town already saw, because the save holds the day it last began. If the game was not saved since that day began, the save still holds the day before, so the next start fires it again. Count days by storing the last date you saw, not by counting calls. Its handler sees the whole day, the first day of a session included: game.calendar_today() lists today's calendar days, game.town() has the date, and game.player() and store.player have the player. A command queued here is applied once the player is free in the town. - `item_picked_up` e = { item, mod_item? }: The player got an item. They picked it up, outdoors or off a room's floor, caught it with the net or the rod, or dug it up with the shovel. It fires once the item is in their pockets, or in the wallet for Bells. It does not fire for anything bought. A fish or a bug that goes into the pockets fires this event and then fish_caught or bug_caught, so a script that counts both counts that catch twice. It does not fire when the pockets were full. Outdoors the game then offers to swap the item for one in the pockets, and no event is sent whatever the player chooses. Indoors a full pocket refuses the pickup. - `scene_entered` e = { scene, name? }: A scene starts, such as the town, a house or a shop. Not in the title demo, at player select or in the intro (the rule own_game_only). - `data_migrated` e = { from, to }: Fires once per town, when mod.json "data_version" differs from the version the town's data was written at. It runs as the town loads, before any other event's handlers run in that town. from is 0 for data from before data_version. If the handler errors, the script stops and the version stays, so the next start tries again. Migrations run in load order. A remote.call from a data_migrated handler into a mod whose own data_migrated has not run in that town yet is refused. Needs data_version. - `hour_changed` e = { year, month, day, hour }: The game's clock reached a new hour. This is the game's own hourly update, midnight included. - `item_bought` e = { item, mod_item?, price, shop, ordered }: The player bought a good for Bells at any counter in the game. It fires as the seller takes the price. shop says which counter: "nook" (Nook's in every size, The City's Nookington's too), "flower" (the flower shop), "redd" (Crazy Redd), "saharah" (her carpet, swapped for one of yours and Bells), "joan" (turnips), "fireworks" (the fireworks show's stall), "shrine" (the New Year fortune slip), "gyroid" (what another player put up at their gyroid) or "villager" (a villager selling you something). Test e.shop == "nook" to keep to Nook's. price is the Bells paid. ordered is true for a Nook's catalog order, which is paid now and mailed tomorrow, so it is not in the pockets yet. Only Nook's and the flower shop sell mod items. A visitor buying in a friend's town gets a plain piece, so mod_item is nil there. Paid services that hand over no good are not purchases and do not fire it. These are the barber, Katrina, the Dream Suite and an Able Sisters design. - `item_sold` e = { item, mod_item?, count, bells, shop }: The player sold for Bells. It fires once the wallet is credited. shop says to whom: "nook" (Nook's in every size, The City's Nookington's too) or "villager" (a villager buying something from your pockets). Nobody else in the game buys. item is the first good, count is how many went and bells is what they fetched. mod_item is the first good's full id when it is a mod item. What another player buys at your gyroid does not fire it. The gyroid hands you the takings later as one sum, with no record of what sold. - `fish_caught` e = { item, pocketed }: A fish was landed. pocketed says whether it went into the pockets. There is no size or length, because the game keeps none for a caught fish. Each kind has one fixed shadow size. Only the fishing tourney makes up a length, when the fish is shown to its host. When pocketed is true, item_picked_up fired for the same catch just before this event. - `bug_caught` e = { item, pocketed }: A bug was netted. pocketed says whether it went into the pockets. When pocketed is true, item_picked_up fired for the same catch just before this event. - `letter_read` e = { sender?, item?, mod_item?, first_time, letter? }: The player chose Read on a letter. item is the present, nil when the letter carries none. letter names the letters file letter it is, when a mod sent it. - `villager_moved_in` e = { villager { id, name, species?, personality? } }: A villager with no house was given one. It fires at the game start after a move-in. A brand-new town fires it for its first villagers. - `visitor_arrived` e = { kind }: A friend is riding into this player's own town. This is a friend visit, on the host's side. kind is "friend". - `command_finished` e = { id, command, ok, via?, code?, message? }: A command this mod queued was applied or refused. When applied, ok is true and via says how (mailbox, post_office, pockets, mail, shown, taken, saved, set, unchanged or played). When refused, ok is false, with a code (command_codes) and a message. Sent only to that mod. - `question_answered` e = { id, choice?, text? }: The player answered this mod's ask, or closed it. choice counts from 1 and text is the answer picked. Both are nil when the window closed with no pick. Sent only to that mod. - `timer_fired` e = { id, name, data? }: A timer this mod set with timer.after is due. It fires once, at the end of a frame's update, in whatever scene the player is in, and the timer is gone before the handler runs. It is an event like any other. Its handlers share one instruction budget, it waits for a later frame when the frame's time is spent, and the commands it queues count against the per-event and per-day caps. At most one timer per mod fires in a frame. A timer that came due while the game was closed fires soon after the town loads. Sent only to that mod. - `villager_answered` e = { villager { id, name, species?, personality? }, choice, text }, returns string|table|nil: The player answered the question this mod's conversation asked (villager_talked returned place = "conversation" with an ask). Sent only to that mod, while the window waits. Return what the villager says next, in the same conversation: a line, or { line, ask } to ask again. Return nil and the talk ends. A reply that is not right is logged and the talk ends. - `button_pressed` e = { button }: A button on the player's controller was pressed. The player's game inputs are the controller the game itself reads, so a keyboard key, a controller button and the on-screen touch pad are all the same button here, with the player's own key and button settings applied. A mod never sees which key was typed: the keyboard reaches it only through the buttons it plays, and nothing reaches it while the game's text editor is open (writing a letter or a name, by keyboard or by controller). Events come once a frame, only while the player's own game is running: releases first, then presses, each in button order. A button already held when play starts, or held through a change of scene or the text editor, is not a press. The C stick is the four c_ buttons. To read the stick, or several buttons held at once, call game.input(). A handler runs at the frame it was sent in unless the frame is already busy, when it can run a frame or two later: game.input() then reads the controller as it is when the handler runs, so a combination is safest tracked from the events themselves. - `button_released` e = { button }: A button on the player's controller was let go. The player's game inputs are the controller the game itself reads, so a keyboard key, a controller button and the on-screen touch pad are all the same button here, with the player's own key and button settings applied. A mod never sees which key was typed: the keyboard reaches it only through the buttons it plays, and nothing reaches it while the game's text editor is open (writing a letter or a name, by keyboard or by controller). Events come once a frame, only while the player's own game is running: releases first, then presses, each in button order. A button already held when play starts, or held through a change of scene or the text editor, is not a press. The C stick is the four c_ buttons. To read the stick, or several buttons held at once, call game.input(). A handler runs at the frame it was sent in unless the frame is already busy, when it can run a frame or two later: game.input() then reads the controller as it is when the handler runs, so a combination is safest tracked from the events themselves. - `player_acted` e = { action, item?, reaction? }: The player started one of the actions below. Only these, never standing, walking or running: poll game.player().state for those. Only the player playing this game: a friend on a visit or another player in The City does not send it. It is the action starting, not its result: axe_swung fires for every swing, and the tree falls or not afterwards. It fires on a visit too, where the player acts in the host's town, and in The City. It changes nothing, so it needs no permission. Lua globals (anything else does not exist): - `on` - `log` - `message` - `game`: `game.time`, `game.day_number`, `game.pockets`, `game.bells`, `game.town`, `game.villagers`, `game.player`, `game.calendar_today`, `game.weather`, `game.place`, `game.input` - `store`: `store.get`, `store.set`, `store.town`, `store.client.get`, `store.client.set`, `store.player.get`, `store.player.set` - `settings`: `settings.get` - `remote`: `remote.add`, `remote.call`, `remote.has`, `remote.version` - `cmd`: `cmd.send_letter`, `cmd.give_item`, `cmd.show_line`, `cmd.ask`, `cmd.take_item`, `cmd.take_bells`, `cmd.save`, `cmd.set_weather`, `cmd.play_sound`, `cmd.set_shop_goods`, `cmd.set_shop_open`, `cmd.set_hat`, `cmd.set_shirt`, `cmd.react` - `rng` - `timer`: `timer.after`, `timer.cancel` Commands (each needs its name in mod.json `permissions`; at most 4 per event; a call returns the id, or nil, a message and a code): - `cmd.send_letter`: Queues a letter in the player's own mailbox. The post office keeps it when the mailbox is full. The save holds an ordinary letter, so it loads without the mod. - `cmd.give_item`: Queues an item into the first empty pocket. With full pockets it comes by letter. Also takes this mod's own new item by its full id (author.mod:thing). A mod item is given with its identity, as a shop sells it, and full pockets refuse it. - `cmd.show_line`: Queues a line shown in a message box with no one speaking, like the game's own "My pockets are full!", once the player is free. One line or question at a time. - `cmd.ask`: Queues a question with 2 to 4 answers in that same speakerless message box. The pick comes back as a question_answered event. - `cmd.take_item`: Asks the player to hand over items from their pockets. The game shows its own question, which names the item, the count and this mod. The mod's name stands between quotes, and a mod item is named as the pockets show it. A script cannot change that text. On yes the items leave the pockets and command_finished says via taken. On no, or when the window closes with no pick, nothing is taken and command_finished carries command-declined. It is refused with command-not-held when the pockets do not hold that many. Only plain pocket slots count. A wrapped present or an item held for a villager's errand is never taken. Items a command cannot give cannot be taken either (money bags, turnips, tickets, grab bags, fossils). It is refused on a visit and in The City, so a lent mod can never take anything. - `cmd.take_bells`: Asks the player to pay Bells from their wallet. The game shows its own question, which names the amount and this mod. The mod's name stands between quotes. A script cannot change that text. On yes the Bells leave the wallet and command_finished says via taken. On no, or when the window closes with no pick, nothing is taken and command_finished carries command-declined. It is refused with command-not-held when the wallet holds less than the amount, so the wallet never goes below zero. The bank account and money bags in the pockets are never touched. It is refused on a visit and in The City, so a lent mod can never take anything. - `cmd.save`: Asks the game to save the town, as the Autosave setting does, for a mod such as a save-anywhere button. The game writes the home save only where the player could save at Gyroid: outdoors in their own town, in free control, with no menu, talk or scene change. It writes a settled copy of the town and never changes the town being played, so nothing is lost or doubled however often it runs. command_finished says via saved, or via unchanged when nothing changed since the last save (nothing is written). It is refused with command-indoors inside a house, a shop or any place that is not the town outdoors, command-busy when the player is not in free control, command-dream in a dream, command-not-ready before a save is loaded or while the page is replacing the save, command-too-soon within commands.save_spacing_seconds of any mod's last save, and command-save-failed when the write itself fails. It is refused on a visit and in The City, because a visitor's game does not hold the town it stands in. It does not run what Gyroid's save does on top: a villager's mood and clothes reach the save at the next change of scene or Gyroid save. - `cmd.set_weather`: Sets the town's weather for the rest of the game day: kind "clear", "rain" or "snow", and for rain or snow an intensity, "light" (when left out) or "heavy". Heavy rain is a storm, with lightning in June to August, and heavy snow is a blizzard. The game changes it as its own weather changes: the last drops or flakes fall, then the new weather fades in with its light and sound. Villagers, fish, bugs and the rain sound follow it as they follow any rainy or snowy day. The next game day the game rolls its own weather again, and a day after rain or snow can bring a rainbow and a gyroid, as after a real rainy day. A reload the same day keeps it. Only weather the game itself could roll on that date is allowed. Clear is always allowed. Rain is allowed from February 25 to November 15, and snow from November 1 to February 24, but neither on the days the game keeps clear: January 1 to 7, April 1 to 8 (the cherry blossoms), April 20, October 31 and December 31. On an event day the event's weather holds, and the player's first day of work for Nook stays dry. Those are refused with command-weather. command_finished says via set, or via unchanged when the town already has that weather as game.weather() reads it: cherry blossom petals and falling leaves count as clear, so on those days "clear" is unchanged and the petals or leaves stay, and putting back the weather a mod read changes nothing. While a change of weather is under way the command waits for it to end. It is refused on a visit and in The City, because the host's game decides the weather and a visitor sees the host's. Needs scope world. - `cmd.play_sound`: Plays one of the game's own sound effects, by its name in sounds.json: a jingle, a menu tick, a page turn. Only this player hears it: in a visit the friend does not, and nothing reaches the town or the save. Every sound in the list is one the game plays once and stops on its own, never a sound that loops. A sound changes nothing, so it does not wait for the player to be free: it plays at the end of the next frame's update, in a talk or a menu too. command_finished says via played. At most commands.sounds_per_event in one event and commands.sounds_per_minute in any minute for each mod (command-event-cap, command-sound-cap). A name not in sounds.json is refused with command-args. While an NES game is being played the game's sound is the NES game's, and a sound is refused with command-no-sound. It is refused in The City. - `cmd.set_shop_goods`: Sets a shop's goods for the rest of the game day, as one more block after the mod's shops.json blocks for that shop. It is set at the call, with no queue, no daily cap and no command_finished, and applies from the next frame, also when the shop is shut, and is gone when the day changes or the game restarts, so set it again in day_started. nil clears it. Only for a shop with goods in the shop table, and refused when a mod later in the load order changes that shop. Needs scope world. - `cmd.set_shop_open`: Opens or shuts a shop for the rest of the game day, as one more block after the mod's shops.json blocks for that shop. true opens it, false shuts it, nil clears it. It is set at the call, with no queue, no daily cap and no command_finished, and applies from the next frame and is gone when the day changes or the game restarts. Only for a shop with open in the shop table, and refused when a mod later in the load order changes that shop. Needs scope world. - `cmd.set_hat`: Puts a picture from the mod's own files on the hat of the player playing this game, in place of the design or the shirt the hat wears. nil takes it off. It is set at the call, with no queue, no daily cap and no command_finished, and shows from the next frame. The picture is the path of a PNG inside the mod, like "hats/stripes.png": exactly 32 x 32 pixels, every pixel opaque, at most 16 colours, as an Able Sisters design. Keep it outside the mod's textures folder. A mod's hat beats a design on the hat. When two mods set one, the mod later in the load order wins. The hat is this player's own, by who they are and their home town, so a hat set at home stays on when they visit a friend or go to The City. Only this player's own screen draws it: friends on a visit and players in The City see the hat as the game would draw it. Nothing is saved: the hat is gone when the game restarts. A reload of the mod's script in developer mode keeps it. Keep the player's pick in store.player and set it again from scene_entered. Away from home store.player starts empty, so set the hat only when the store holds a pick: a nil there is no reason to take it off. It changes only how the player looks, so it works in a Just you mod, on a visit and in The City. - `cmd.set_shirt`: Puts a picture from the mod's own files on the shirt of the player playing this game, in place of the clothes they wear. nil takes it off. It is set at the call, with no queue, no daily cap and no command_finished, and shows from the next frame. The picture is the path of a PNG inside the mod, like "shirts/stripes.png": exactly 32 x 32 pixels, every pixel opaque, at most 16 colours, as an Able Sisters design, and it wraps the body and the sleeves the way a design does. Keep it outside the mod's textures folder. It beats the clothes the player wears: putting on other clothes changes what is underneath, and the picture stays on top until the mod takes it off. The hat matches the shirt, as in the game, so with no design or mod hat on the hat it wears the picture too. When two mods set one, the mod later in the load order wins. The shirt is this player's own, by who they are and their home town, so a shirt set at home stays on when they visit a friend or go to The City. Only this player's own screen draws it: friends on a visit and players in The City see the clothes the player wears. Nothing is saved: the shirt is gone when the game restarts, and the save keeps the clothes the player wears. A reload of the mod's script in developer mode keeps it. Keep the player's pick in store.player and set it again from scene_entered. Away from home store.player starts empty, so set the shirt only when the store holds a pick: a nil there is no reason to take it off. It changes only how the player looks, so it works in a Just you mod, on a visit and in The City. - `cmd.react`: Plays one of the reactions from the reactions bar on the player's own character: "hooray", "dance", "hug", "thanks", "ouch", "trip", "spin", "hide" or "pose". It is the same reaction the bar plays, so friends on a visit and players in The City see it as they see one from the bar. It is set at the call, with no queue, no daily cap and no command_finished: the game is asked there and then, and the reaction plays from the next frame for at most 1.5 seconds; any move from 0.3 seconds on walks out of it. Only from standing, walking or running, and only while the player is free: refused (command-busy) during a menu, a talk, a message, a door, a cutscene or a scene change, and refused (command-cannot-react) when the game says no, such as while sitting, swinging a tool or holding furniture. One reaction at a time: once one is taken the player is in it, so another call in the same moment, or in a player_acted handler (the player is in the action that just started), is refused with command-busy. React from a later moment, such as a timer. At most commands.reacts_per_minute a minute for each mod (command-minute-cap). It moves only the player's own body and changes nothing saved, so it works in a Just you mod, on a visit and in The City. When it plays, player_acted fires with reacted. Refusal codes (branch on the code, never on the message): - `command-shop` (retry: never): A shop command the shop cannot take: the shop is not in the shop table, it has no goods or no open, or a mod later in the load order changes that shop. - `command-permission` (retry: never): The command is not in mod.json permissions. - `command-args` (retry: never): Wrong arguments, such as their shape, a length, the paper or the choices. - `command-item` (retry: never): An item the command cannot hand out, or an unknown item or letter id of the mod's own. Also sent in command_finished when the mod's item or letter was gone by the time the game applied the command. - `command-event-cap` (retry: next-event): More than commands.per_event commands in one event. - `command-queue-full` (retry: later): The mod's queue, or the game's, is full. - `command-day-cap` (retry: tomorrow): The per-day limit for this command in this town is used up. - `command-city` (retry: later): Commands are off in The City. - `command-visiting` (retry: later): On a visit, only the town owner's game changes the town. - `command-lent-home` (retry: never): A lent mod acting outside the host's town. It arrives in command_finished, never as the return of a cmd call. - `command-no-room` (retry: later): No room now. The mailbox and the post office are full, or the pockets are full for a mod item. The command still counts against the day's cap, so do not try again in a loop. - `command-not-shown` (retry: never): The line or question cannot be drawn in the window, because the text has too many pages. The command still counts against the day's cap. - `command-not-held` (retry: later): A take the player cannot meet. The pockets do not hold that many of the item in plain slots, or the wallet holds fewer Bells. - `command-declined` (retry: later): The player said no to a take's question, or closed it with no pick. Nothing was taken. - `command-client-setting` (retry: never): The event read a client setting, and a client setting cannot decide what the town gets or gives up. Make the setting world, or do not read it in an event that sends a letter, gives an item, or takes an item or Bells. - `command-not-ready` (retry: later): A save before the player's save has loaded, or while the page is replacing or restoring the save. - `command-indoors` (retry: later): A save anywhere but the town outdoors: a house, a shop, a museum, the train. Inside a house the furniture still holds the items kept in it, so the game would save the house with its storage empty. - `command-picture` (retry: never): cmd.set_hat's or cmd.set_shirt's picture is not in the mod, or is not a 32 x 32 PNG with opaque pixels and at most 16 colours. - `command-busy` (retry: later): The player is not free now: a menu, a talk, a message window, a door, a cutscene, a tool swing or a scene change has them. For cmd.save, also right after the game itself settled this scene for a save that did not finish, until the next change of scene. For cmd.react, also an action they just started (as in a player_acted handler) or a reaction already playing. Try again from a later moment. - `command-dream` (retry: later): A save in a dream town. A dream is never written to the player's save. - `command-too-soon` (retry: later): A save within commands.save_spacing_seconds of the last save by any mod, or a second save while this mod's last one is still waiting. - `command-save-failed` (retry: later): The game could not write the save file. The town in play is unchanged. - `command-weather` (retry: later): A weather the game would not have today: snow outside the months it snows, rain outside the months it rains, any weather but the event's on an event day, or rain on the player's first day of work for Nook. The date decides, so the next day may allow it. - `command-sound-cap` (retry: later): A sound when this mod already played commands.sounds_per_minute sounds in the last minute, counting the ones still waiting. Wait and play it later. - `command-no-sound` (retry: later): A sound while an NES game is being played: the game's sound belongs to the NES game until it ends. - `command-cannot-react` (retry: later): cmd.react: the game did not take the reaction. It plays only while the player stands, walks or runs, so not while sitting, lying, swinging a tool or holding furniture, and something more important (a talk, a door, a bee) outranks it. - `command-minute-cap` (retry: later): cmd.react: the mod already played commands.reacts_per_minute reactions this minute of the game clock. Try again next minute. Retry rules: try tomorrow on `command-day-cap`. Try later, from a later event, on `command-queue-full`, `command-city`, `command-visiting`, `command-no-room`, `command-not-held`, `command-declined`, `command-not-ready`, `command-indoors`, `command-busy`, `command-dream`, `command-too-soon`, `command-save-failed`, `command-weather`, `command-sound-cap`, `command-no-sound`, `command-cannot-react`, `command-minute-cap`. Try in the next event on `command-event-cap`. Do not try again on `command-shop`, `command-permission`, `command-args`, `command-item`, `command-lent-home`, `command-not-shown`, `command-client-setting`, `command-picture`. timer.after refusal codes (it returns the id, or nil, a message and a code): - `timer-args` (retry: never): Wrong arguments, such as the minutes, the name or the data. Also when the script has no timer_fired handler. - `timer-limit` (retry: later): The mod already has timers.per_mod timers waiting in this town. - `timer-no-town` (retry: later): No town is loaded yet. The script's main chunk runs before the save loads. - `timer-no-clock` (retry: later): The game clock is not set. It reads a date before the year 2000, so there is no minute to count from. - `timer-store-full` (retry: later): The timer does not fit in this mod's town store (store.bytes), or the store could not be written. Dependency codes (remote.version(mod) returns the version, or nil, a message and one of these; remote.call to an absent optional dependency returns the same three): - `dependency-absent`: The mod is not installed, is switched off, did not load, or has no running script. - `dependency-version`: The mod loaded, but its version is outside the range this mod names. - `dependency-undeclared`: The mod is not in this mod's depends or optional_depends. Key limits: ZIP 16 MiB; 256 lines per messages file, 400 bytes each; script 200,000 instructions per event (the stop; wall-clock backstops of 125 ms per event, 250 ms for the main chunk at start, and 3 runs in a row over 8 ms, all stretched up to 8x on a slow device), 4 MB memory; store 8 KB per mod per town. All limits: `reference/api.md`. ### Common texture names Any-palette (`$`) names: each covers every time of day and stretch of the year it is drawn in. A tree crown name covers golden trees too (same crown, gold palette). - Tree crown (grown broadleaf, fruit and golden trees) (February 25 to December 9, except April 1 to 8): `tex1_64x64_a67216e4ad55d908_$_8.dds` - Tree crown, cherry blossom days (April 1 to 8): `tex1_64x64_ac6a2be34281d4e2_$_8.dds` - Tree crown, winter (snow on top) (December 10 to February 24): `tex1_64x64_53d6cc5ace654ac7_$_8.dds` - Cedar crown (February 25 to December 9): `tex1_64x64_2913073a15235562_$_8.dds` - Cedar crown, winter (December 10 to February 24): `tex1_64x64_136aa80a0926d0a3_$_8.dds` - Palm fronds (February 25 to December 9): `tex1_128x32_9dff2c84fba803e5_$_8.dds` - Palm fronds, winter (December 10 to February 24): `tex1_128x32_53b283fa3171bbdd_$_8.dds` - Grass (3 variants) (February 25 to December 9): `tex1_32x32_626709d910129694_$_8.dds`, `tex1_32x32_903adc6355e36f59_$_8.dds`, `tex1_32x32_e96fecd242518c9f_$_8.dds` - Grass, winter (3 variants) (December 10 to February 24): `tex1_32x32_e2ab673814e71af6_$_8.dds`, `tex1_32x32_cfa57a6e6f966d11_$_8.dds`, `tex1_32x32_82f28ec4199a45be_$_8.dds` - Cliff faces (3 variants) (February 25 to December 9): `tex1_64x64_99c780e750314916_$_8.dds`, `tex1_64x64_16de5cbb85d58cc0_$_8.dds`, `tex1_64x64_f628105fb6e026fd_$_8.dds` - Cliff faces, winter (3 variants) (December 10 to February 24): `tex1_64x64_0dd181f7c8e1d9e1_$_8.dds`, `tex1_64x64_e5488c12d43d6cbc_$_8.dds`, `tex1_64x64_64ac9d75399172f0_$_8.dds` - River and pond banks (3 variants) (February 25 to December 9): `tex1_64x64_1218fdfe9c963f24_$_8.dds`, `tex1_64x64_78690dcebd874a3b_$_8.dds`, `tex1_64x64_2d865e307f1a0fdc_$_8.dds` - River and pond banks, winter (3 variants) (December 10 to February 24): `tex1_64x64_2ec0ba79769bedc7_$_8.dds`, `tex1_64x64_b6437b8020145bc6_$_8.dds`, `tex1_64x64_9438dc9288174b5a_$_8.dds` ### The playac-mod tool A command line tool (Node.js 18.17 or newer) with three commands: `check` (a folder or a .zip; Lua syntax by the game's own parser), `pack` (writes `-.zip` beside the folder) and `dev` (serves the folder to the game). Start a mod from an example repository or a starter kit. Share it on the website. `playac-mod help` lists the commands and `playac-mod --help` shows one command's options. Write commands as `playac-mod ...`, never `npx playac-mod ...`. Install it with the line on https://playaconline.com/modding/cli/#install, which names one release by its address and gives its SHA-256. Never install or run the tool by its bare name from the npm registry (no `npx playac-mod`, no `npm install playac-mod`): a package there by that name is not the game's. Without Node, use the no-Node route: write the files, ZIP them, and install in the game with Settings, Mods, Install from a file, Choose a file (the same checks run). "Choose ZIP" is a different button: it uploads a mod to share it. ## What a mod can and cannot do Can: - Replace any texture the game draws with your own art, as `.dds` or `.png`. - Add villager lines: a line goes in one of five places in a talk, the same in a talk pool's `"place"` and a script's talk table: `before` the hello, as the `hello` (an everyday hello only), as the `topic` after a chat answer (its `topics` name which: `small_talk` by default, `trade`, `letter`, `memory`, `hint`, `news` or `"any"`), `after` the topic, or the whole `conversation`. Every pool and every script line names its place: there is no default, and a pool or a plain string return without one is refused. With no code, talk pools (`content.talk`) keep a line to a personality or villager, a season, a time of day, the weather or a calendar `day`. A script's `villager_talked` returns a talk table `{ place, line, topics, ask }` or a list of them; a conversation's `ask` sends the pick to `villager_answered`. A line is a string or a list of up to 8 pages. - Change the game's shops, each by its id (`nook`, `flower`, `redd`, `saharah`, `fireworks`, `able`, `barber`, `dream`, `katrina`), with one block shape: goods and prices, `own_goods`, opening and shutting, service prices, a name and lines, each block kept to hours, a time of day, a season, the weather, weekdays, months or a setting with `when`. A block with `when` applies at once, while it holds. At Nook's the goods of a block with no `when` show from the next morning's restock (the first play on a day at or after 6:00 AM). - Add new furniture on a game piece's model (`content.items`), sold in your shops or given by a script. - Letter templates (`content.letters`), calendar days with a bulletin board notice and a letter, and talk pools kept to a calendar `day` for the day's lines. - Scripts on every event listed above, reading the date, pockets, Bells, town, villagers; a per-town store and a per-player one (`store.player`: a town has up to 4 residents); settings the player sets; calls between mods (`remote`). - Commands, declared in `permissions`, applied at the end of a frame's update (before it is drawn): see the list above. Daily caps are per mod per town (for every resident together: a safety limit), and a command counts when it is applied. Cannot (do not promise these): - Add villagers, buildings, acres, music, or new kinds of item other than house furniture on a game model. - Add a shop of its own, or give a shop a field the shop table does not list for it. - Give Bells, or take them without the player's yes. `give_item` refuses money, and `take_bells` shows the game's own question first. - Run code every frame, change the game's code or memory, read files, reach the internet, or run JavaScript. There is no `io`, `os`, `require`, `load` or `debug`. - Change anything in The City (every command is refused there) or a friend's town while visiting (letters, items and takes are refused). ## Rules (a mod breaking these is refused or removed) - Only the author's own work. No textures, models, music or text taken or traced from any Nintendo game or any other game, film, show or brand. A PNG saved from the model viewer is the game's art: use it only to see the size and layout, and draw a new picture. A recolour, hue shift, filter, touch-up or trace of a game texture is NOT original and cannot be shared (fine in the player's own game); say so plainly when asked to recolour one for sharing. Unchanged copies are refused automatically. - No Nintendo or franchise names or logos in a mod's name, id, description or pictures. - `"assets_original": true` in mod.json is the author's promise of the above. - Nothing sexual, hateful, gory or graphically violent, or holding personal information. Scripts must not try to slow or break the game. - Sharing needs an account, age 13 or older, two-factor sign-in, and accepting the mod rules. Full rules: https://playaconline.com/wiki/mod-rules/ ## Pick the path Ask what they want to make, then follow ONE of these. Each ends with a mod that installs. ### 1. Artist (textures, no tools needed) 1. Find the name. Open `https://playaconline.com/viewer/` (the model viewer; it reads the player's own disc, like the game), pick the model (a villager, tree, rock, furniture, clothing, tool or building), press **Textures**, pick the texture and press **Copy name**. For a texture with a palette (grass, trees, cliffs) press **Any palette** instead: the `$` name, `tex1_32x32_626709d910129694_$_8`, shows the art at night and in every season, so keep the `$`. **Save PNG** saves the picture for its size and layout. The common names (trees by season, cedars, palms, grass, cliffs, banks) are listed under "Common texture names" above. 2. Start from a mod that works: the texture kit (a ZIP in the newest "Starter kits and AI pack" release of playac-mods, linked from `https://playaconline.com/modding/downloads/`; the grass as a green check) or the Springtime Town example repo (`playac-example-springtime-town`, its grass textures). There is no export that makes a mod: never tell the user to look for one. 3. Draw a NEW picture (2x or 4x the size is fine; smaller looks blurry) and save it in `textures/` as `.png` or `.dds` under exactly the copied name. The saved PNG is the game's art: only a guide to the layout. 4. Delete the kit's pictures the user did not replace (unchanged game textures are refused when shared). Edit mod.json: your own id, name, authors. 5. ZIP the folder (Finder Compress or Windows Send to; the folder or the files inside it both work). Keep other ZIPs out of the folder: a `.zip` inside a mod is refused. Settings, Mods, "Install from a file", **Choose a file**, then **Restart now**. Texture facts: names are `tex1_x___.dds` (or `.png`; no palette part for a texture without a palette; `$` in place of the palette hash matches any palette; a `$` file is loaded once and shared by every palette, and any mod's exact-palette file wins over it for that palette). A `.dds` must be BC7, DXT1, DXT5 or uncompressed 32-bit RGBA (either channel order: RGBA or BGRA/A8R8G8B8), ONE level, no mipmaps (the game draws a DDS with mipmaps, but the mod list refuses it). A `.png` is drawn too: at most 2048 x 2048, and all mods' PNGs together at most 96 MB of pixels (24 MB on a phone). Do not keep a `.png` and a `.dds` of the same texture: the game uses only one. A file may carry a label in front of the name so the folder stays readable: `bookshelf-top_tex1_32x32_626709d910129694_$_8.png` is the same texture as `tex1_32x32_626709d910129694_$_8.png`. The label is 1 to 40 lowercase letters, digits and dashes, then ONE underscore, then the name exactly as copied; the game matches on the `tex1_` part only, in `textures/` and in an item's own textures folder. Suggest a label when you name files for the user. A label with a capital letter, a space or an underscore of its own is refused (`texture-label`), and two files that are the same texture once the labels are taken off are refused (`texture-label-twice`): different labels never make different textures. A mod's texture wins over the HD pack. On a phone all switched-on mods share 24 MB unpacked. ### 2. Writer (lines, shops, letters, calendar days; a text editor) 1. Make a folder with `mod.json` (template below) and the content file. 2. Villager lines, no script: a talk pools file (`content.talk`): lines by personality or by villager, optionally kept to a `season` (spring, summer, fall, winter), a `time` (morning, day, evening, night), the `weather` (clear, rain, snow) or a calendar `day`, with a `chance` in 100 talks it fits (default 100), and a required `place` (before, hello, topic, after, conversation; a topic line is small talk unless `topics` says more). A topic line is said whenever the game picks one of its topics, so a villager can say several a day. See `reference/api.md` and the Springtime Town example. Use this first for lines by personality, season, time or weather; a script only for lines that depend on something else (an item in the pockets, a count the script keeps). 3. Lines a script says: `messages.json` (one file, at the top of the mod) and a tiny script (the talk example below). Every player sees a mod's texts as written. 4. A shop: `shops.json` (template below), `"scope": "world"`. Themed goods that are furniture (lanterns, a tea set) need the mod's own items (`content.items`), which the flower shop and Nook's both sell; the flower shop cannot show the game's own furniture. 5. A letter: `content.letters` with `id`, `header` (`{player}` for the name), `body` (6 lines), `footer` (the sign-off, up to 32 characters) and an optional `sender` (up to 8, the name in the mailbox list, which otherwise shows the footer cut to 8: "The Lantern Keepers" reads "The Lant"; `check` warns), `item`, `paper`. A script mails it with `cmd.send_letter`, a calendar day with `letter`. 6. A calendar day: `content.calendar` (a file with a top-level `"days"` list) where a day has an optional `board` (world scope) and an optional `letter` (the id of one of the mod's `content.letters` letters, mailed on the day with NO script, once per town); a day's villager lines are talk pools with its `id` as their `day`, ahead of other pools on the day. `"week": 2, "weekday": 5` means the second Friday of the month (week n = the nth such weekday; `"last"` = the last). To test: set the date to today while testing; or move the device clock (the game reads it at start; back up the save first). Installed mid-day, the notice posts the next time the player walks outside that day; `day_started` does not fire again after a restart the same day, so a script uses `game.calendar_today()`. 7. ZIP the folder (the folder or its files, either works), Settings, Mods, "Install from a file", **Choose a file**, **Restart now**. ### 3. Scripter (Lua, ideally VS Code and Node) 1. Start from the script starter kit (`templates/script-kit` in the playac-mods repository) or an example repository: copy the folder and change `id` in mod.json. For the editor, a starter kit ZIP from the release already has `.playac/playac.lua`; otherwise copy `api/playac.lua` from the playac-mods repository to `.playac/playac.lua` (LuaLS types; also at https://playaconline.com/schemas/playac.lua); the JSON schemas are in its `api/` too. 2. `playac-mod check` runs every rule the game runs at install, lists every problem at once (JSON errors with line and column), and FAILS on a script the game would stop at load: a Lua syntax error (checked with the game's own Lua 5.4 parser, built into the tool) and an `on()` for an event not in `scripts.events`. It warns about what the game accepts but probably not as meant (cmd.* not in permissions, a shop good the game leaves out, a texture the mod list refuses). `check some.zip` checks a ZIP exactly as the Mods tab reads it. `playac-mod pack` writes `-.zip` NEXT TO the mod folder (the same bytes every time) and prints its content hash. Hidden files and folders (`.playac/`, `.claude/`, `.vscode/`) and a top-level `CHANGELOG.md` never go in the ZIP; README.md does, so it is for players. 3. Test without zipping. Opening the game with `?moddev=1` only shows the Developer section: it loads nothing by itself. The whole loop is: (a) run `playac-mod dev` in the mod folder and leave it running; (b) open the game with `?moddev=1`; (c) Settings, Mods, Developer, "Load a mod you are making"; (d) put the address the tool printed in **playac-mod dev address** (the box already holds `http://127.0.0.1:2604`; the tool uses the next free port when 2604 is taken) and press **Connect** (the tool answers only game pages at playaconline.com, its dev site and http://localhost:5173; for a page at another address, start it with `playac-mod dev --origin `, or Connect says the dev server refused this site); (e) press **Restart now** once. The tool's terminal says each step: `connected: ` after Connect, `loaded in the game: ` after the restart, `reloaded ` for each save the game takes, `Restart now to load: ` for a change that waits, and `disconnected: ` when the page closes. No `loaded in the game` line means the game did not run it: read the Mod log. Without Node, **Choose folder** (the folder with mod.json) replaces (a) and (d). Always tell the user to press Connect: the page reaches the tool only then, and again after the page is reloaded. After that, saving reloads it in the running game: lines, shops, `talk`, `letters` and `calendar` files at once (shop goods on the next visit, a talk pool on a villager's first talk of the day), `main.lua` restarts the script with its store kept, textures are drawn again, and the `items` file is read again at once (a new name or price shows the next time it is shown or offered; a new base is what new pieces are made of, while pieces already in the town keep the base they were made of; a removed item's pieces show as their base and are it again when it is back; the Mod log says which applies). A mod.json change needs a restart, and so does giving a removed item's pieces a new id (a `renames` entry in mod.json). Errors (with a Lua traceback), stops and refused files are in the Mods tab's **Mod log**. While a mod is loaded this way, friend visits and sharing are off. 4. Without Node: write the files by hand from the templates here, ZIP them and install with **Choose a file**: the install runs the same checks. ### 4. Power user (sharing, versions, dependencies, multiplayer) - Raise `version` for every shared update; a version can never be replaced. - Share on the website only: Settings, Mods, Share a mod (two-factor on; a code from the authenticator app opens a 15-minute window in that browser). Upload the ZIP with 1 to 4 screenshots and an optional changelog line, or paste `github.com/owner/repo@tag` to import a tagged GitHub release: the tag must match mod.json's version, and the import reads screenshots from `.playac/screenshots/` (200 to 4096 px a side and at most 3840x2160 pixels in all, as an 8 bit PNG or a standard JPEG) and an optional line from a `## ` section in `CHANGELOG.md` (never packed, so editing it keeps the content hash). The playac-mod tool does not upload. - "Mods you shared" in the Mods tab lists every uploaded version and its state: Waiting for review, Listed, Older version, Withdrawn, Refused (with the reason), Removed. A listed version can be withdrawn there and listed again. - A mod it can use but does not need: `"optional_depends": { "author.lib": ">=1.0.0" }` (same shape as `depends`; an id goes in only one of `depends`, `optional_depends`, `conflicts`). The mod always loads; a present one (installed, on, loading, in range) loads first. `remote.version("author.lib")` returns its version or `nil, message, code` (`dependency-absent`, `dependency-version`, `dependency-undeclared`); `remote.call` to an absent optional dependency returns the same three and raises nothing. Ask in an event, not at the top of the script: two mods that use each other load in the player's order, so the first one's top level runs before the other exists. - A library and a mod that needs it: developer mode loads ONE folder, and that copy counts as installed for `depends`; install the other from its ZIP (`playac-mod pack`), either way round. A library declares `exports` (name -> one-line description) in mod.json. - `data_migrated` (`e.from`, `e.to`) runs as the town loads, NOT at the restart, before any other event in that town. - `data_migrated` runs only for data that exists: on a fresh install there is none, so it is not called, and the first `store.set` writes at the current `data_version`. `from` is 0 for data saved before the mod set a `data_version`. - World mods (`"scope": "world"`) that count must match for friend visits: same mods, same versions, same order, same world settings. A setting is `"scope": "world"` (the default: part of the town, compared, the host's value when mods are lent) or `"scope": "client"` (the player's own: never compared or sent; each player keeps theirs on a visit). Mark a cosmetic toggle `client`. A client setting may decide only what its own player sees or hears: in an event that read one with `settings.get`, `cmd.send_letter`, `cmd.give_item`, `cmd.take_item` and `cmd.take_bells` are refused with `command-client-setting`, so never read one in an event that sends, gives or takes, and never keep its value (a variable, `store`, a timer's `data`) to use in one. Just you mods (`"scope": "client"`) never block a visit. When every World mod of the host that counts is a reviewed version from the mod list, the visitor can load them for that visit only: nothing is installed, they run with the host's world settings and the visitor's own client settings (a text setting changed from its default must pass the site's word checks, or the visit is refused) and an empty store that is never kept, and at the visitor's home (the restarts before and after the trip) their shop, Nook goods, board notices, items, renames and commands do nothing. A mod installed from a file cannot be lent, so publish World mods. A World mod that depends on a Just you mod cannot load for a friend without that Just you mod, so the visit is refused: World mods should depend only on World mods. - In The City, World mods' shops and board notices switch off, mod items are off, and every command is refused; textures, lines and scripts keep running for the player, but nothing a script commands applies there. ## mod.json ```json { "schema": 1, "api": 2, "id": "yourname.my-mod", "name": "My Mod", "version": "1.0.0", "authors": ["yourname"], "description": "What it does, in a sentence or two.", "scope": "client", "content": { "textures": "textures/", "messages": "messages.json" }, "scripts": { "main": "main.lua", "events": ["villager_talked", "day_started"] }, "assets_original": true } ``` - Required: `schema` (1), `api` (1), `id`, `name`, `version`, `authors`, `scope`, `assets_original: true`. - `id`: `author.mod-name`, lowercase letters, digits and dashes, one dot. Never change it after sharing. `playaconline`, `official`, `admin` and `example` are reserved author names. - `version`: `"1.0.0"` style, three numbers, no leading zeros. - `scope`: `"client"` (only the player sees it) or `"world"` (changes the town for visitors; REQUIRED for shops and board notices). - `content`: the keys listed above. Paths are exact, case-sensitive, relative to mod.json. - `scripts.events`: every event the script uses with `on()`, each once. An `on()` for an event NOT in `events` raises an error at load and the whole script stops (the mod still installs): always add the event to `events`. A library mod that only offers `remote.add` functions still lists one event and registers no handler for it. - `settings`, one of each type: `[{ "name": "greet", "type": "bool", "label": "Say hello", "default": true }, { "name": "price", "type": "number", "label": "Fruit price", "default": 600, "min": 100, "max": 5000 }, { "name": "drink", "type": "choice", "label": "Drink", "default": "tea", "choices": ["tea", "coffee"] }, { "name": "motto", "type": "text", "label": "Shop motto", "default": "", "max_length": 40 }]`. name 1 to 32 of `a-z 0-9 _` starting with a letter; label 1 to 60 characters; optional description up to 200; at most 16. Read with `settings.get("price")`. - `permissions`: every command the script uses (`cmd.`). - JSON is strict: double quotes, no comments, no trailing commas, no key twice. - A key the game does not know is refused, in mod.json and in every data file except messages, and the message names the closest key: `mod.json: unknown key "permisions" (did you mean "permissions"?)`. ## shops.json (World mods only) ```json { "shops": { "flower": { "when": { "hours": { "from": "15:00", "to": "01:00" } }, "open": true, "own_goods": false, "goods": [{ "item": "0x2800", "price": 600 }], "name": "Tea Stall", "lines": { "greeting": "Welcome to the tea stall!" } }, "nook": { "goods": [{ "item": "0x1110", "price": 1800 }, { "item": "0x2205", "price": 900 }] } } } ``` - Each key under `"shops"` is a shop id: `nook`, `flower`, `redd` (Crazy Redd), `saharah`, `fireworks`, `able` (Able Sisters), `barber`, `dream` (the Dream Suite), `katrina`. Any other key is refused (`shop-id`). A shop takes one block, or a list of 1 to 8 blocks (`shop-blocks`). - A block's keys, in this order: `when`, `open`, `own_goods`, `goods`, `price_percent`, `buy_back_percent`, `services`, `name`, `lines`. Each means the same on every shop. A block needs a key besides `when` (`shop-block-empty`). - Which fields each shop has is the shop table in `reference/api.md` (online https://playaconline.com/modding/guides/shops/#table). Nook's: `when`, `open`, `own_goods`, `goods` (1 to 16), `price_percent`, `buy_back_percent`. The flower shop: `when`, `open`, `own_goods`, `goods` (1 to 6, six bench spots of one kind), `price_percent`, `name`, `lines` (slots `greeting` and `stock`). Crazy Redd, Saharah, the fireworks stall: `when`, `own_goods`, `goods` (1 to 6), `price_percent`. Able Sisters (`design`), Katrina (`fortune`): `when`, `services`. The barber shop (`haircut`): `when`, `open`, `services`. The Dream Suite (`dream`): `when`, `services` (it keeps no hours). A piece of furniture the game has no model for (the kadomatsu 0x1220 and the like) is refused as a good everywhere (`shop-item-no-model`). A field a shop does not have is NOT refused: the game leaves it out, the rest of the block applies, and the mod's row on the Mods tab names the shop and the field (`shop-field-ignored`). - `when`: the block applies only while every key holds; leave it out for always. `hours` `{ "from": "HH:MM", "to": "HH:MM" }` (24-hour, from and to differ, to may pass midnight), `time` (morning, day, evening, night), `season` (spring, summer, fall, winter), `weather` (clear, rain, snow), `weekday` (a list, `"monday"` to `"sunday"`), `month` (a list, 1 to 12), `setting` (the name of one of the mod's own bool settings with scope world: the block applies while it is on). A good may carry a `when` of its own too. - `open`: `true` opens the shop while the block applies, also when its own hours have it shut; `false` shuts it. Leave it out for the shop's own hours. - `own_goods`: `true` (the default) puts the goods in at most half the spots of their kind, rounded up, and the shop's own keep the rest. `false` makes the goods of the applying blocks the whole stock, every other spot bare. A night shop of only your goods is `"when"` hours, `"open": true` and `"own_goods": false` (the After Hours example). No mod changes Nook's kind of day: the grab bag sale's bags and Halloween's candy stand beside the mod's goods, and the raffle (the last day of the month) takes the whole shop. - `price_percent` (1 to 1000): the percent of its own price the shop asks for every good with no price of its own. `buy_back_percent` (1 to 1000, Nook's): the percent of his usual pay for what the player sells, never more than he asks for it; not turnips. `services`: a service's price in Bells by name (`shop-service` for a name the shop does not have). `name` (1 to 40 characters, one line): the flower shop's door sign while shut. `lines`: a slot to a line or a list of 1 to 8 (the keeper picks one each time), each 1 to 160 characters with at most 3 line breaks (`shop-line-slot` for a slot the shop does not have). - Inside one mod every block whose `when` holds applies: their goods together, and for a single value (`open`, `own_goods`, a percent, a service, a line slot) the last of them that sets it. When two mods change the same shop, the one LAST in load order has that shop whole and the earlier mod's row says its change is not used (`shop-replaced`); two mods on different shops both apply. - A script with the permissions can add one block after the JSON ones for the rest of the game day: `cmd.set_shop_goods(shop, goods)` and `cmd.set_shop_open(shop, on)`, `nil` clears. - `item` is a STRING `"0x"` + 4 hex digits, or one of the mod's own items by full id (`"yourname.my-mod:lamp"`), at Nook's and the flower shop only. Each item once per block. `price` optional, whole Bells 1 to 99999; below the good's floor it is raised to it (the floor is what Nook pays; a town fruit at the flower shop is 500). - What each shop may stock is in `reference/items.md` (flower and Nook's columns). The flower shop needs a good with a shop table model: none of the game's own furniture has one, but the mod's OWN items always work there. Nook's sells the game's furniture, clothing, stationery, carpets, wallpaper, tools, umbrellas, paint, saplings, flower bags; not fruit. Money, tickets, grab bags, turnips and fossils never. A refused good is left out, with the reason on the Mods tab row after a restart; `playac-mod check` warns first. ## messages.json ```json { "greet": "Hello there!", "shop.hours": "We open at three." } ``` Ids 1 to 48 of `a-z 0-9 _ . -`; at most 256 lines; each 1 to 400 bytes. Lines wrap by width, not by a count of characters: a line holds 180 pixels of the game's font (about 24 letters, more of narrow ones, fewer of wide ones), 4 lines to a page; characters the font lacks show as `?`. A script reads its own line with `message("greet")` and another mod's with `message("author.mod:greet")` (nil when that mod is not installed). `content.messages` names one `.json` file, never a folder. ## Scripts (Lua 5.4) ```lua -- main.lua: the top level runs once at start, BEFORE any town is loaded. -- Register handlers here. Read and save the store only inside events. -- Every handler gets ONE table, e. A field with nothing to say is nil. on("villager_talked", function(e) -- e.villager = { id, name, species, personality } if store.get("met_" .. e.villager.id) then return nil end store.set("met_" .. e.villager.id, true) return { place = "before", line = message("greet") } -- said before their usual hello -- another place: return { place = "after", line = { "Page one.", "Page two." } } end) on("day_started", function(e) -- e = { year, month, day, weekday } local today = ("%04d-%02d-%02d"):format(e.year, e.month, e.day) if store.get("last_day") ~= today then -- a restart the same day does not fire it again; count by date store.set("last_day", today) store.set("days", (store.get("days") or 0) + 1) end log("day", store.get("days")) end) ``` - `store` is per mod per TOWN (8 KB): `store.get` answers nil and `store.set` is refused at the top level, before a town loads. A town has up to 4 residents and they share `store`; `store.player.get/set` is per mod, per town, per player, inside the same 8 KB: keep anything one resident earns (a quest, today's gift) there. `game.player()` is `{ name, id }`. `store.client` is per browser. Strings, numbers, booleans only; `set(key, nil)` deletes. - Every `store.set`, `store.player.set` and `store.client.set` writes the mod's file in the save folder before it returns. The browser keeps the save folder at the game's next save sync (a game save, and a mod-data upload at most every 2 minutes for the cloud). A tab closed before that sync loses the last sets. - Ids are numbers in Lua (`e.item == 0x2800`). JSON files write them as `"0x2800"` strings. `cmd.*` take a number, `"0x2800"` or the mod's own `"author.mod:thing"`. - `rng()`, `rng(n)`, `rng(m, n)`: each call gives the mod's next number for this town and game day, so calls differ and a reload carries on (it cannot reroll). `math.random` and `math.randomseed` are not available: calling one stops the script with an error that says to use `rng()`. `game.day_number()` is the game day as one whole number. - `log(...)` writes a line in the Mods tab's **Mod log** and the browser console as `[Mods] : ...` (20 per event, 500 per session). - `villager_talked`: every mod's handler runs in load order; the FIRST line returned for a place takes it, and a conversation takes the whole talk and stops the event. Textures and shops: the LAST mod wins (so a mod loaded in developer mode, which loads last, wins textures and shops but not a talk place). Talk pools fill the places no script took; pools from every mod are pooled, not ranked. `command_finished` and `question_answered` go only to the mod that asked, `villager_answered` only to the mod whose conversation asked, `data_migrated` only to the mod whose data version moved; every other event runs every mod's handlers. - Commands (`cmd.send_letter{...}`, `cmd.give_item(item)` ...) return the command's id, or `nil, message, code`; the outcome arrives as a `command_finished` event: `e.ok` true with `e.via`, or `e.ok` false with `e.code` and `e.message`. The code says whether to try again (the codes are listed above and in `reference/api.md`). Mark a reward as given only in `command_finished` when `e.ok`; follow the retry word of the code in the "Refusal codes" list above, and the "Retry rules" line under it. A code marked `later` or `next-event` must not mark the reward as refused for good. A command refused with `command-no-room` or `command-not-shown` still used one of the day's cap, so try again from a later event, never in a loop. A refusal when the game applies the command is also written to the Mod log. At most 4 per event; daily caps and every command's arguments in `reference/api.md`. A question with answers: ```lua -- mod.json: "permissions": ["ask", "show_line"], "scripts": { "main": "main.lua", "events": ["scene_entered", "question_answered"] } local asked = false on("scene_entered", function(e) -- e = { scene, name }: name is "player_house", "museum"..., or nil if asked then return end asked = true cmd.ask{ text = "Join the fishing derby?", choices = { "Sign me up!", "No thanks" } } end) on("question_answered", function(e) -- e = { id, choice, text }: choice counts from 1; nil if closed with no pick if e.choice == 1 then cmd.show_line("You're in the derby!") end end) ``` - A letter body is 192 pixels a line in the game's font: about 30 characters of ordinary English a line, 6 lines (capitals, m and w are wider: 19 W's fill a line; words never split). Keep text a script builds under about 150 characters with at most 5 line breaks; `cmd.send_letter` refuses one that does not fit at once: it returns `nil, message, code`. Plain US keyboard characters only. - `fish_caught` gives `e.item` (the fish) and `e.pocketed`; there is no size or length. - `item_picked_up` also fires for a fish or a bug that goes into the pockets, just before `fish_caught` or `bug_caught`, and for anything dug up. Never count the same catch in both handlers. - Over a limit, or on any Lua error (syntax errors included), the script stops for the session and the Mods tab row says why with the line; the rest of the mod keeps working. `pcall` does not get around the budget. Payloads are copies. No `__gc`, and no table with a `__len` metamethod passed to `table.insert`, `remove`, `sort` or `concat`. ## Testing checklist 1. `playac-mod check` (or install the ZIP: the Mods tab refuses with the reasons). Read every warning. 2. Restart the game and read the mod's row in Settings, Mods: anything the game itself refused (shop items, a script that stopped) is listed there. 3. Script output: the Mods tab's **Mod log** (log() lines, errors with a traceback, stops, refused files, live), and the browser console (F12, Console), lines starting `[Mods] yourname.my-mod:`. 4. Something broke the game? Settings, Mods, **Start without mods**, or add `?nomods=1` to the play address. 5. Before sharing: no file you did not make, unchanged textures deleted, version raised, description says what it does, a screenshot ready. ## Sharing and review 1. Sign in at playaconline.com with two-factor sign-in on. Settings, Mods, Share a mod. The first time, confirm age 13+ and accept the mod rules. Then enter the code from the authenticator app. 2. Upload the ZIP, or use Import from GitHub, which shows under the upload form once the code is accepted. The automatic checks answer at once (the same rules, plus image checks: unchanged game textures, DDS formats, mipmaps). 3. A moderator reviews it. There is no fixed time: the version waits in the queue until a moderator gets to it. Refusals and removals come with a reason code (`review-*` in `reference/errors.md`) and a note. Every upload and its review decision show in Settings, Mods, under Share a mod. The site sends no mail. 4. Updates: raise `version` and upload again. Players who have it see "Update available". A version the moderators removed is switched off in every player's game. ## Troubleshooting: always use the errors catalogue When the user pastes an error, find it in `reference/errors.md` (search a distinctive phrase; the page's, the site's and the game's wordings are all listed) and answer with: the code, what it means in one sentence, and the exact fix applied to THEIR file. Link `https://playaconline.com/modding/errors/#`. A Lua syntax error (`main.lua:7: 'end' expected near `) is `script-syntax`; any other Lua error with a file and line is `script-error`: open that line. Common ones: no mod.json at the top of the ZIP (`zip-no-manifest`: zip the folder's contents, not a parent folder); a `"scope": "client"` mod with shops (`shops-need-world`); `"item": 0x2800` without quotes (`shop-item`); an event used with `on()` but missing from `scripts.events` (`script-on-event`); a misspelt key (`unknown-key`); a texture that does not show (the name must be exact, copy it with Copy name in the model viewer (/viewer/, Textures); a DDS saved with one level; a later mod in load order may replace it). ## How to answer - Give COMPLETE files, ready to save, never fragments with "...". - Check every file against the rules above before you give it: required keys, `"api": 2`, string item ids, `scripts.events` matching `on()` calls, permissions matching `cmd.` calls, scope world for shops, limits. - Prefer the smallest mod that does what they asked. Say what it cannot do instead of faking it. - Remind them to raise `version` when they change a shared mod. - No Nintendo names in ids, names or descriptions you write. --- ## Page: https://playaconline.com/modding/ ## Make mods for Play AC Online A mod is a ZIP file that changes the game without changing its code. It can hold textures, villager lines, shop stock, furniture, letters, calendar days and Lua scripts. You make a mod on your own computer and install it in your own game to try it. When it is ready, you can share it with every player. You do not need our source code or any special software to start. A browser, the game and a text editor or paint program are enough. You do need the game running with a town loaded. The game runs from your own disc file. If you have not played yet, start at Your disc, then see Set up your computer. ## Pick your path I draw Draw new grass, a shirt or a sign. Find the texture's name in the model viewer, then draw your own picture. No command line. I write Give villagers new lines, write letters and calendar days, or restock a shop. You edit text files from a starter kit. I code Write Lua 5.4 scripts that handle 20 events. A script can send letters, give items and ask questions. I want it all Load order, dependencies, World mods and visits, the command line tool and publishing from GitHub. ## What a mod can do - Textures. Replace any texture the game draws with a .dds or .png of the same size or bigger. - Lines. Villagers say your lines. Talk pools, with no code, make them part of their small talk, by season, time of day or weather if you like. A script can put a line anywhere in a talk, or hold a whole conversation. - Shops. Change the goods, prices, opening hours and keeper's words of 9 shops: Nook's store, the flower shop, Crazy Redd's tent, Saharah, the fireworks stall, Able Sisters, the barber shop, the Dream Suite and Katrina's tent. Each shop has the fields its row in the shop table lists. See Shops. - New items. Add house furniture on one of the game's furniture models. Sell it in your shops or give it from a script. See New items. - Letters and calendar days. A script can mail a letter to the player. A calendar day can post a bulletin board notice, add lines and send a letter. See letters, calendar days and villager lines. - Scripts. Lua 5.4 code handles 20 events: villager_talked, day_started, item_picked_up, scene_entered, data_migrated, hour_changed, item_bought, item_sold, fish_caught, bug_caught, letter_read, villager_moved_in, visitor_arrived, command_finished, question_answered, timer_fired, villager_answered, button_pressed, button_released and player_acted. A script can read the date, the pockets, the Bells, the town and its villagers. It keeps saved data per town. - Commands. A script may ask the game to send letter, give item, show line, ask, take item, take bells, save, set weather, play sound, set shop goods, set shop open, set hat, set shirt and react. Each command is declared in mod.json and applied at the end of a frame's update. See Commands. - Settings. Players set your mod's options in the Mods tab. See Settings. - Dependencies. A mod can build on other mods. See Dependencies. ## What a mod cannot do - Add villagers, buildings, acres or music. The only new items are house furniture on a game model. - Change a shop outside the shop table, such as Joan's turnips. - Give Bells, or take them without asking. give_item refuses money, and take_bells shows the game's own question, which the player must answer yes. - Change the town map, or another player's town or save. - Run a command in The City. On a visit to a friend's town, the commands that mail, give or take (send_letter, give_item, take_item, take_bells) are refused, and so are save and set_weather. play_sound still plays there, heard only by the visitor. - Run code every frame. Scripts answer events and timers, and a timer waits at least one game minute. A script changes the game only through the commands its mod.json lists in permissions. - Change the game's code, read your files or reach the internet. This will never change. See the safety model. ## How it works - Make a folder with a mod.json file and your content. A starter kit gives you both. - ZIP it. - In the game, open Settings, then Mods. Under Install from a file, choose Choose a file. - Choose Restart now. Mods load when the game starts. - Look at your change in the game. A problem shows in red on your mod's row. - When it works, share it from Share a mod in the same tab. A moderator checks it, then everyone can install it. ## See working mods The cookbook shows 4 complete example mods, file by file. Each one is its own public repository on GitHub, laid out the way the GitHub import wants a mod. We install the same files in our own tests, so they work with the current game. Downloads links the starter kits and the examples as ZIPs, on GitHub. - Springtime Town: Textures and villager lines, no code. Repository. - After Hours: Nook's at night, an item with its own pictures. Repository. - Harvest Post: Calendar days, letters, a script with commands and a timer. Repository. - Button Tricks: Buttons, looks, weather, reactions and saves. Repository. These docs describe mod API level 1, the level every mod uses. See API levels and the changelog. ## Source and help - The examples, the starter kits, the setup guides and the tool's source are in the public repository on GitHub. - For a wrong fact or a broken example, open an issue there. - For a question about making a mod, ask on Discord. ## Just want to play with mods? The player page, Mods, covers installing, switching and reporting mods. --- ## Page: https://playaconline.com/modding/ai/ ## Make mods with an AI assistant An AI assistant does not know this game's mod rules on its own, and it invents functions that do not exist. The AI pack gives it the whole mod API, every error with its fix, the working examples and the items a shop can stock. With the pack, it writes mods that install the first time. Download the AI pack (ZIP) It downloads from GitHub, from a release of the public playac-mods repository, next to the starter kits. ## What is in it playac-mod-ai.zip: ``` playac-mod-ai/ .claude/skills/playac-mod/SKILL.md Claude Code .claude/skills/playac-mod/reference/ api.md, errors.md, examples.md, items.md AGENTS.md Codex, Cursor, Aider, Zed and others .github/copilot-instructions.md GitHub Copilot README.txt ``` The pack holds one set of instructions in three forms. It also holds reference files made from the game's own rules, so they match the game. The Claude Code and Copilot files sit in hidden folders, so they are never packed into your mod's ZIP. ## Claude Code - Unzip the pack into your mod's folder, the one that holds mod.json. For a new mod, use an empty folder. The ZIP holds one folder, playac-mod-ai. - Move what is inside playac-mod-ai up, so .claude/ sits next to mod.json. The names start with a dot, so Finder hides them. Cmd+Shift+. shows them. In a terminal, run: in a terminal: ``` cd my-mod unzip /path/to/playac-mod-ai.zip mv playac-mod-ai/.claude playac-mod-ai/.github playac-mod-ai/AGENTS.md . rm -r playac-mod-ai ``` - Run claude in that folder and ask for a mod. For example: "Make a mod that restocks the flower shop with fruit and opens it at night." - The playac-mod skill loads by itself whenever you talk about the mod. To have it in every project, copy .claude/skills/playac-mod into ~/.claude/skills/ instead. ## Other assistants - GitHub Copilot. Keep .github/copilot-instructions.md in the mod's folder. Copilot Chat reads it. - Codex, Cursor, Aider, Zed and others. Put AGENTS.md at the top of the mod's folder, and keep .claude/skills/playac-mod/reference/ too. AGENTS.md points into that folder for the API, the errors and the examples. Without the folder, the assistant can read the same files in llms-full.txt. - AGENTS.md is a .md file, so playac-mod pack puts it in your mod's ZIP. That is harmless. To keep it out, put it one folder up. - ChatGPT, Claude.ai or another chat. Upload SKILL.md and the reference/ files to the chat or a project, then ask. Or give it llms-full.txt, which is all of the modding docs as one text file. ## Good to know - Test what the assistant writes. Install the ZIP from Settings, Mods, Choose a file, or run playac-mod check. The game checks every rule. - When something is refused, paste the message to the assistant. It finds the fix in the errors list. - You are the author. The rules apply to what an assistant makes for you too. Share only original work, with no art from any game. - The pack changes when the mod API does. Download it again after a game update. --- ## Page: https://playaconline.com/modding/changelog/ ## Mod API changelog This page lists what each version of the mod API holds. The "api" number in your mod.json says which level the mod was made for. The game runs level 1, at version 1.1. ## How the API changes - A new field in a table the game hands a script, or a new value it can return, cannot break an old mod, so it changes nothing here. - A new command, event, query or limit is a minor version of the level, such as 1.1. Nothing is removed or changed, so a mod keeps saying "api": 1 and works on the game it was made for and every later one. A playac-mod older than the version that added a name does not know it, and says the tool may be out of date. - Only a change that would refuse or change an existing mod is a new level. Mods made for the old level keep running by its rules while the game still supports it. - A level is read for at least 12 months after the next level ships. - Before a feature is removed, it is marked deprecated for at least two more levels and at least 90 days, whichever is later. - A new level listed here will say how to move a mod up to it. ## Version 1.1 26 November 2026. Additions, nothing removed or changed: a mod made for 1.0 works unchanged and keeps saying "api": 1. Commands cmd.save, cmd.set_weather and cmd.play_sound are applied at the end of a frame's update; cmd.set_hat, cmd.set_shirt and cmd.react are set at the call. The events button_pressed, button_released and player_acted. The queries game.input(), game.weather() and game.place(), and game.player() now also tells where the player stands and what they are doing. A playac-mod older than 1.1.0 does not know these names and says the tool may be out of date. Version 1.1 adds: ## Lua - game.weather: The weather where the player is now: { kind, intensity }, or nil before a town is loaded. kind is clear, rain or snow, the words shops and talk pools use: cherry blossom petals and falling leaves count as clear. Indoors it is the weather outside, on the island it is the island's, and on a visit it is the weather of the town being visited. Reading it changes nothing and needs no permission. - game.place: Where the player is now: { scene, name, island, acre, acre_x, acre_z, unit_x, unit_z }, or nil before a town is loaded. scene and name are the scene, as scene_entered gives them. The acre fields are there only outdoors in the town or on the island, standing in an acre the town map shows. It names the acre and the square inside it, one of the 16 by 16 squares of an acre, the way the town map does; game.player() gives the exact position. Both are only ever the player's own: a mod never sees where another player is. On a visit it is the place in the town being visited, the same town game.town() names. Reading it changes nothing and needs no permission. - game.input: The player's game inputs right now: { a, b, x, y, z, l, r, start, dpad_up, dpad_down, dpad_left, dpad_right, c_up, c_down, c_left, c_right, stick_x, stick_y }. Each button is true while held. The player's game inputs are the controller the game itself reads, so a keyboard key, a controller button and the on-screen touch pad are all the same button here, with the player's own key and button settings applied. A mod never sees which key was typed: the keyboard reaches it only through the buttons it plays, and nothing reaches it while the game's text editor is open (writing a letter or a name, by keyboard or by controller). It is nil while the text editor is open. Use it for a stick or a combination, such as L held while A is pressed; use button_pressed for a single press. It reads the controller when it is called, which in a button event that waited for a busy frame is a frame or two after the press. ## Commands - cmd.save: Asks the game to save the town, as the Autosave setting does, for a mod such as a save-anywhere button. The game writes the home save only where the player could save at Gyroid: outdoors in their own town, in free control, with no menu, talk or scene change. It writes a settled copy of the town and never changes the town being played, so nothing is lost or doubled however often it runs. command_finished says via saved, or via unchanged when nothing changed since the last save (nothing is written). It is refused with command-indoors inside a house, a shop or any place that is not the town outdoors, command-busy when the player is not in free control, command-dream in a dream, command-not-ready before a save is loaded or while the page is replacing the save, command-too-soon within commands.save_spacing_seconds of any mod's last save, and command-save-failed when the write itself fails. It is refused on a visit and in The City, because a visitor's game does not hold the town it stands in. It does not run what Gyroid's save does on top: a villager's mood and clothes reach the save at the next change of scene or Gyroid save. - cmd.set_weather: Sets the town's weather for the rest of the game day: kind "clear", "rain" or "snow", and for rain or snow an intensity, "light" (when left out) or "heavy". Heavy rain is a storm, with lightning in June to August, and heavy snow is a blizzard. The game changes it as its own weather changes: the last drops or flakes fall, then the new weather fades in with its light and sound. Villagers, fish, bugs and the rain sound follow it as they follow any rainy or snowy day. The next game day the game rolls its own weather again, and a day after rain or snow can bring a rainbow and a gyroid, as after a real rainy day. A reload the same day keeps it. Only weather the game itself could roll on that date is allowed. Clear is always allowed. Rain is allowed from February 25 to November 15, and snow from November 1 to February 24, but neither on the days the game keeps clear: January 1 to 7, April 1 to 8 (the cherry blossoms), April 20, October 31 and December 31. On an event day the event's weather holds, and the player's first day of work for Nook stays dry. Those are refused with command-weather. command_finished says via set, or via unchanged when the town already has that weather as game.weather() reads it: cherry blossom petals and falling leaves count as clear, so on those days "clear" is unchanged and the petals or leaves stay, and putting back the weather a mod read changes nothing. While a change of weather is under way the command waits for it to end. It is refused on a visit and in The City, because the host's game decides the weather and a visitor sees the host's. Needs scope world. - cmd.play_sound: Plays one of the game's own sound effects, by its name in sounds.json: a jingle, a menu tick, a page turn. Only this player hears it: in a visit the friend does not, and nothing reaches the town or the save. Every sound in the list is one the game plays once and stops on its own, never a sound that loops. A sound changes nothing, so it does not wait for the player to be free: it plays at the end of the next frame's update, in a talk or a menu too. command_finished says via played. At most commands.sounds_per_event in one event and commands.sounds_per_minute in any minute for each mod (command-event-cap, command-sound-cap). A name not in sounds.json is refused with command-args. While an NES game is being played the game's sound is the NES game's, and a sound is refused with command-no-sound. It is refused in The City. - cmd.set_hat: Puts a picture from the mod's own files on the hat of the player playing this game, in place of the design or the shirt the hat wears. nil takes it off. It is set at the call, with no queue, no daily cap and no command_finished, and shows from the next frame. The picture is the path of a PNG inside the mod, like "hats/stripes.png": exactly 32 x 32 pixels, every pixel opaque, at most 16 colours, as an Able Sisters design. Keep it outside the mod's textures folder. A mod's hat beats a design on the hat. When two mods set one, the mod later in the load order wins. The hat is this player's own, by who they are and their home town, so a hat set at home stays on when they visit a friend or go to The City. Only this player's own screen draws it: friends on a visit and players in The City see the hat as the game would draw it. Nothing is saved: the hat is gone when the game restarts. A reload of the mod's script in developer mode keeps it. Keep the player's pick in store.player and set it again from scene_entered. Away from home store.player starts empty, so set the hat only when the store holds a pick: a nil there is no reason to take it off. It changes only how the player looks, so it works in a Just you mod, on a visit and in The City. - cmd.set_shirt: Puts a picture from the mod's own files on the shirt of the player playing this game, in place of the clothes they wear. nil takes it off. It is set at the call, with no queue, no daily cap and no command_finished, and shows from the next frame. The picture is the path of a PNG inside the mod, like "shirts/stripes.png": exactly 32 x 32 pixels, every pixel opaque, at most 16 colours, as an Able Sisters design, and it wraps the body and the sleeves the way a design does. Keep it outside the mod's textures folder. It beats the clothes the player wears: putting on other clothes changes what is underneath, and the picture stays on top until the mod takes it off. The hat matches the shirt, as in the game, so with no design or mod hat on the hat it wears the picture too. When two mods set one, the mod later in the load order wins. The shirt is this player's own, by who they are and their home town, so a shirt set at home stays on when they visit a friend or go to The City. Only this player's own screen draws it: friends on a visit and players in The City see the clothes the player wears. Nothing is saved: the shirt is gone when the game restarts, and the save keeps the clothes the player wears. A reload of the mod's script in developer mode keeps it. Keep the player's pick in store.player and set it again from scene_entered. Away from home store.player starts empty, so set the shirt only when the store holds a pick: a nil there is no reason to take it off. It changes only how the player looks, so it works in a Just you mod, on a visit and in The City. - cmd.react: Plays one of the reactions from the reactions bar on the player's own character: "hooray", "dance", "hug", "thanks", "ouch", "trip", "spin", "hide" or "pose". It is the same reaction the bar plays, so friends on a visit and players in The City see it as they see one from the bar. It is set at the call, with no queue, no daily cap and no command_finished: the game is asked there and then, and the reaction plays from the next frame for at most 1.5 seconds; any move from 0.3 seconds on walks out of it. Only from standing, walking or running, and only while the player is free: refused (command-busy) during a menu, a talk, a message, a door, a cutscene or a scene change, and refused (command-cannot-react) when the game says no, such as while sitting, swinging a tool or holding furniture. One reaction at a time: once one is taken the player is in it, so another call in the same moment, or in a player_acted handler (the player is in the action that just started), is refused with command-busy. React from a later moment, such as a timer. At most commands.reacts_per_minute a minute for each mod (command-minute-cap). It moves only the player's own body and changes nothing saved, so it works in a Just you mod, on a visit and in The City. When it plays, player_acted fires with reacted. ## Events - button_pressed: A button on the player's controller was pressed. The player's game inputs are the controller the game itself reads, so a keyboard key, a controller button and the on-screen touch pad are all the same button here, with the player's own key and button settings applied. A mod never sees which key was typed: the keyboard reaches it only through the buttons it plays, and nothing reaches it while the game's text editor is open (writing a letter or a name, by keyboard or by controller). Events come once a frame, only while the player's own game is running: releases first, then presses, each in button order. A button already held when play starts, or held through a change of scene or the text editor, is not a press. The C stick is the four c_ buttons. To read the stick, or several buttons held at once, call game.input(). A handler runs at the frame it was sent in unless the frame is already busy, when it can run a frame or two later: game.input() then reads the controller as it is when the handler runs, so a combination is safest tracked from the events themselves. - button_released: A button on the player's controller was let go. The player's game inputs are the controller the game itself reads, so a keyboard key, a controller button and the on-screen touch pad are all the same button here, with the player's own key and button settings applied. A mod never sees which key was typed: the keyboard reaches it only through the buttons it plays, and nothing reaches it while the game's text editor is open (writing a letter or a name, by keyboard or by controller). Events come once a frame, only while the player's own game is running: releases first, then presses, each in button order. A button already held when play starts, or held through a change of scene or the text editor, is not a press. The C stick is the four c_ buttons. To read the stick, or several buttons held at once, call game.input(). A handler runs at the frame it was sent in unless the frame is already busy, when it can run a frame or two later: game.input() then reads the controller as it is when the handler runs, so a combination is safest tracked from the events themselves. - player_acted: The player started one of the actions below. Only these, never standing, walking or running: poll game.player().state for those. Only the player playing this game: a friend on a visit or another player in The City does not send it. It is the action starting, not its result: axe_swung fires for every swing, and the tree falls or not afterwards. It fires on a visit too, where the player acts in the host's town, and in The City. It changes nothing, so it needs no permission. ## Limits - commands.sounds_per_event: play_sound calls one mod may make in one event. They count toward commands.per_event too. - commands.sounds_per_minute: Sounds one mod may play in any 60 seconds of the player's real clock, the ones waiting to play included. A sound counts when the game plays it. One refused does not count. A sound has no daily limit. - commands.weather_per_day: set_weather per mod per game day in each town. A change counts when the game changes the weather. One refused, or one that found the town already in that weather (via unchanged), does not count. The count is per town and shared by its residents, not per player. It is a safety limit, not a game rule: a sky that changes every few minutes is no weather. - commands.saves_per_day: save per mod per game day in each town. A save counts when the game writes the town. One refused, or one that found nothing changed (via unchanged), does not count. The count is per town and shared by its residents, not per player. It is a safety limit, not a game rule: every save also uploads the town to the cloud. - commands.save_spacing_seconds: The least time between two saves by mods, all mods together, on the player's real clock. A save asked for sooner is refused with command-too-soon. A refused save does not start the wait; one that found nothing changed does. - commands.hat_side: The width and the height of a picture cmd.set_hat puts on the hat or cmd.set_shirt on the shirt. It must be exactly this size, the size of an Able Sisters design. - commands.hat_colors: The most colours a hat or shirt picture may have, as a design. Every pixel must be opaque. Colours are kept at 5 bits a channel, as the game keeps a design's. - commands.hat_file_bytes: The largest PNG file cmd.set_hat or cmd.set_shirt reads. A 32 x 32 picture is far smaller. - commands.reacts_per_minute: cmd.react per mod per minute of the game clock. A reaction the game refused does not count. It is a safety limit, so a mod cannot keep a player reacting in a friend's town or The City. The Button Tricks example uses them all, one per D-pad button. ## Level 1 16 November 2026. The first level. Content is textures (a file may carry a readable label before its name), lines (a messages file), shops (each by its id in the shop table, from Nook's store and the flower shop to Katrina's tent, one block shape for every shop, each block applying while its when holds), new furniture on a vanilla base with pictures of its own (an items file, renames), letter templates, calendar days and villager line pools. Scripts get the events in the events list, each handed one table. They also get log, message, the game queries, a store per town with a part per player and one per browser, settings, remote calls between mods, a seeded rng and timers on the game clock. Eight commands are declared in permissions: six (cmd.send_letter, give_item, show_line, ask, take_item, take_bells) are applied at the end of a frame's update, and two (cmd.set_shop_goods, set_shop_open) are set at the call. Mods also have depends and conflicts with version ranges, and data_version with the data_migrated event. Mods can name optional_depends, and a setting can be world or client. Level 1 (version 1.0) contains: ## mod.json - $schema: Optional. The JSON Schema an editor checks mod.json against, for autocomplete and errors as you type. The game ignores it. - schema: The manifest format. Always 1. - api: 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. - id: 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). - name: 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. - version: 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. - authors: 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. - description: Optional text of at most 500 characters. null is refused. Leave the key out instead. - tags: 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). - scope: 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. - content: 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. - scripts: A Lua script and the events it listens to. events may list data_migrated only with a data_version. - permissions: 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. - exports: 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_original: Must be true. It is your promise that the mod holds only work its authors made, never files taken from the game. - renames: 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. - depends: 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_depends: 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. - conflicts: 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_version: 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. - settings: 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. ## Files - shops: Changes shops, each by its id: "nook", "flower", "redd" and the rest of the shop table. A shop takes one block, or a list of blocks. A block says what changes (goods, open, own_goods, prices, services, name, lines) and, with "when", when. Every field means the same on every shop. The shop table says which fields each shop has; a field a shop does not have is left out and the mod's row says so (rule shop_fields). While a block applies its goods join the shop's own, in at most half the spots of their kind (rounded up), or with "own_goods": false they are the whole stock. When several blocks apply at once their goods are sold together, and for a single value the last of them counts. The game itself, not the page or the mod list, refuses goods with no shelf model, money, turnips, tickets, grab bags, fossils and reserve ids, and raises a price below the item's buy-back to the buy-back. items.json lists what may be stocked. A good may be an item of the same mod, by its full id, at Nook's and the flower shop. Without a price a good takes the shop's own price. Shops are off in The City. When two switched-on mods change the same shop, the one later in the load order has that shop whole and the other's change to it is not used (rule load_order_last_wins). The earlier mod's row says so. - messages: Lines a script or another mod can use, by key. A script reads its own with message("key") and another mod's with message("author.mod:key"). This file cannot carry a $schema key, because every key is a line. Point your editor at messages.schema.json in its settings instead. - textures: A folder of replacement textures, named the way Dolphin names a custom texture. A mod's texture beats the HD pack. Among mods, the one lower in the list wins. The exception is that a file for one exact palette beats any mod's "$" (every palette) file for the same texture (rule load_order_last_wins). All mods' DDS textures together may take 96 MB on the graphics card, or 24 MB on a phone. Their PNGs may take 96 MB of pixels, or 24 MB on a phone. A texture past its limit is left out and named on its mod's row. A mod's texture is read a little each frame after it is first drawn, so the game's own texture shows for a moment before it. Find a texture's name in the model viewer (/viewer/). - scripts: Lua 5.4 source text, run once when the game starts. Bytecode is refused. The script registers handlers with on() and returns nothing. Each mod has its own Lua state, and mods cannot see each other's globals. - items: New furniture, each on a vanilla base piece. The game also refuses a base with no model, fossils, gyroids, clothing, design pieces and pieces a player carries as an item: umbrellas, fish, bugs, tools, balloons, fans, pinwheels and diaries. In the save, a mod item is its base piece. A file beside the save (mod-items.json) maps it back. Removing the mod therefore leaves the base piece behind, and reinstalling restores the mod item. That file belongs to the save it was written beside. Next to another save of the same town, such as a backup put back or an older town file imported, it is not used. Those pieces are then plain base pieces again. An item may carry its own pictures ("textures"). They replace the base piece's textures on that item alone, in a house and on Nook's floor. On the flower shop's bench a furniture good is a leaf. Every other copy of the base keeps its look. - mod-items sidecar: /save/card_a/mod-items.json. The game writes it beside the home save, and a mod never reads or writes it. It records which placed or carried base pieces are which mod item, and which renames have run. It rides in the cloud save and in a friend visit's town copy. - letters: Letter templates that a mod command (send_letter) mails through the mailbox, named ":". The game wraps the body at the paper's width in its own font and refuses one that needs more than 6 lines. It also refuses a present that is money, turnips, a ticket, a grab bag, a fossil or not an item. Either scope. - calendar: Calendar days: dated days with safe effects only, and no script. A day can have a notice on the town bulletin board. The notice is posted once on the day in the player's own town, never on a visit or in The City, and needs scope world. A day can have villager lines: talk.json pools that name the day's id as their "day", in any place of the talk. A day with no notice and no letter is a date for those pools. A day can have a letter from the same mod's letters file. The letter is mailed once on the day to the player's mailbox in their own town, never on a visit or in The City, and counts against the mod's daily letter limit. A day cannot add decorations, because the game has no data format for them. - talk: Villager lines placed in a villager's talk. A talk is the hello, which ends in a menu (an errand, a chat, never mind); when the player chats, the game picks a topic, fresh every time: small talk (plain chat, the time of day, the weather, the month), a trade, a letter they got, a memory, a hint, or news of an event. Every pool's "place" says where its line goes; there is no default: "before" the hello (the hello and everything after it still play), as the "hello" (the menu and the topic still play; only an everyday greeting is replaced, never a hello with news such as a bee sting or a collection finished), as the "topic" (instead of the topic the game picked when it is one of the pool's "topics", small talk when it names none; the talk ends after it, as small talk does), "after" the topic (one more message before a chat ends), or the whole "conversation" (no hello, no menu, no topic: the pool's pages, then the talk ends). A line is one page or a list of pages. A special talk (a first meeting, an errand, a villager moving out, the first-job errands) never uses a pool, nor do a new player's first ten chats, whose topics are tips. For each place, the most specific pools that fit are used: this villager, else this personality, else everyone. A pool fits when its season, time, weather and calendar day, if it names them, are the ones now. Each pool that fits rolls its chance; the lines of the pools that pass are put together, from every mod, and one is picked, never the one this villager said last when there is another. When the most specific pools all roll no, that place stays the game's. A script's villager_talked line takes its place first. A pool kept to a calendar "day" speaks only on that day, in its place, like any other pool. A conversation pool is used only when no script took any place. Nothing is saved. Either scope. Pools run in The City too. ## Lua - on: Registers a handler for an event. Call it while the mod's own script loads, not from inside a handler and not from a function another mod calls with remote.call. The event must be in mod.json's scripts.events. At most 16 handlers per event. A handler gets one table, e, holding the event's fields. - log: Writes a line to the Mods tab's Mod log and the browser console as "[Mods] : ...". Arguments are joined with spaces. A line is cut at 299 bytes. At most 20 lines per event and 500 per session. A refused cmd.* or timer.* call writes a line of its own, and those lines count toward the same two limits. A script error or stop is written to the Mod log too, with a Lua traceback, whatever the limits. The log keeps the newest 400 lines of all mods. When it is full, the oldest line of the mod with the most lines goes first, so one mod cannot push out another mod's lines. - message: A line from a messages file. "key" reads this mod's own line, and "author.mod:key" reads another mod's. Returns nil when there is no such line. - game.time: The game's clock now. - game.day_number: The game clock's day as one whole number: days since 2000-01-01. It goes up by one each game day, so it tells one day from the next without date maths. - game.pockets: The items the player holds, in slot order: { { slot, item, mod_item }, ... }. Only held items are listed, so an empty slot has no entry. Returns {} when the pockets are empty or before a town is loaded. - game.bells: The wallet, or nil before a town is loaded. - game.town: The town: { name, id, year, month, day, hour, minute, weekday, season }, or nil before a town is loaded. season is spring, summer, fall or winter, the word talk pools and shops use. - game.villagers: The town's villagers: { { id, name, species, personality }, ... }. Returns {} before a town is loaded. - game.player: The player playing this game: who they are, where they stand, what they hold and what they are doing, or nil before a town is loaded. A town has up to 4 residents, each playing it from their own save slot. Every call reads the game as it is now, so it is cheap to call from any event, such as button_pressed or timer_fired. On a visit it is the visitor, standing in the host's town. Where the player stands and what they do (every field after id) is nil while the scene is still being built, such as in day_started as the game starts. - game.calendar_today: The ids of this mod's own calendar days that fall on the town's date today, in file order. Returns {} when there are none, or before a town is loaded. Only the calling mod's days are listed. - store.get: A value this mod saved in this town, or nil. It is nil while the main chunk runs. Integers come back as integers. - store.set: Saves a string, number or boolean under a key in this town. nil deletes the key. Keys are up to 64 bytes and strings up to 1024. A set that would take this town's store over 8 KB raises an error and changes nothing. So does a set before a town is loaded, in the main chunk. - store.town: Which town the store is for now, as an opaque text that changes when the town does ("v:..." away from home). nil before a town is loaded. Compare it to reload what you keep in locals when the player moves to another town. - store.client: The per-browser store. It has the same get, set and limits, with one store per mod per browser whatever town is loaded. - store.player: This player's part of the town store. It has the same get and set, per mod, per town, per player (game.player().id). It lives inside the mod's town store and shares its 8 KB. Before a town is loaded, get answers nil and set raises an error. With a town but no player in the game yet, get answers nil and set raises its own error (no player is in the game yet). When a resident is deleted, everything mods saved for them here is deleted too and its room is given back. A new resident in that save slot starts with nothing. On a visit it lives in memory only. - settings.get: A setting's value: the player's, else the default. It is a boolean, an integer or a string. nil for a name the mod does not declare. - remote.add: Offers a function to other mods, while the script loads. Names are 1 to 32 of a-z 0-9 _, at most 32 per mod. With mod.json "exports", only the names it lists. - remote.call: Calls a function another running mod offers. Its errors come back as yours, and it keeps running. When the mod is one of this mod's optional_depends and it is absent, nothing is called and nothing is raised: the call returns nil, a message and a code from dependency_codes. - remote.has: Whether a running mod offers that function. - remote.version: Whether a mod this one names in depends or optional_depends is present, and at what version. Returns its version, such as "1.2.0", when it loaded inside the range. Returns nil, a message and a code from dependency_codes when it did not. Ask in an event. In the main chunk an optional dependency that the cycle rule placed after this mod has loaded no script yet. - rng: Seeded random numbers. rng() gives a number in [0,1), rng(n) a whole number 1..n and rng(m, n) a whole number m..n. The seed is the mod, the town, the game day and how many numbers this mod has drawn in this town on this game day. Each call in a day therefore gives another number, and a reload cannot reroll. The count is saved with the town store at the end of a run that drew numbers, and a reload carries on from it. If the tab closes before that write, the same numbers come again, never new ones. A new game day starts the count at 0, and changing the game's clock gives other numbers. The count is kept in memory only away from home, for a lent mod and before a town loads. Inside a remote.call, the called mod draws from its own counter. math.random and math.randomseed are not available. Use rng(). - timer.after: Sets a timer that fires once, at least that many game minutes from now. It returns the timer's id. When it is refused it returns nil, a message and a code (timer_codes). Setting a timer rewrites the town store, so it is charged to the event's budget like store.set. - timer.cancel: Cancels a waiting timer of this mod in this town. It answers true when there was one. A timer that already fired, or an id from another town, answers false. ## Commands - cmd.send_letter: Queues a letter in the player's own mailbox. The post office keeps it when the mailbox is full. The save holds an ordinary letter, so it loads without the mod. - cmd.give_item: Queues an item into the first empty pocket. With full pockets it comes by letter. Also takes this mod's own new item by its full id (author.mod:thing). A mod item is given with its identity, as a shop sells it, and full pockets refuse it. - cmd.show_line: Queues a line shown in a message box with no one speaking, like the game's own "My pockets are full!", once the player is free. One line or question at a time. - cmd.ask: Queues a question with 2 to 4 answers in that same speakerless message box. The pick comes back as a question_answered event. - cmd.take_item: Asks the player to hand over items from their pockets. The game shows its own question, which names the item, the count and this mod. The mod's name stands between quotes, and a mod item is named as the pockets show it. A script cannot change that text. On yes the items leave the pockets and command_finished says via taken. On no, or when the window closes with no pick, nothing is taken and command_finished carries command-declined. It is refused with command-not-held when the pockets do not hold that many. Only plain pocket slots count. A wrapped present or an item held for a villager's errand is never taken. Items a command cannot give cannot be taken either (money bags, turnips, tickets, grab bags, fossils). It is refused on a visit and in The City, so a lent mod can never take anything. - cmd.take_bells: Asks the player to pay Bells from their wallet. The game shows its own question, which names the amount and this mod. The mod's name stands between quotes. A script cannot change that text. On yes the Bells leave the wallet and command_finished says via taken. On no, or when the window closes with no pick, nothing is taken and command_finished carries command-declined. It is refused with command-not-held when the wallet holds less than the amount, so the wallet never goes below zero. The bank account and money bags in the pockets are never touched. It is refused on a visit and in The City, so a lent mod can never take anything. - cmd.set_shop_goods: Sets a shop's goods for the rest of the game day, as one more block after the mod's shops.json blocks for that shop. It is set at the call, with no queue, no daily cap and no command_finished, and applies from the next frame, also when the shop is shut, and is gone when the day changes or the game restarts, so set it again in day_started. nil clears it. Only for a shop with goods in the shop table, and refused when a mod later in the load order changes that shop. Needs scope world. - cmd.set_shop_open: Opens or shuts a shop for the rest of the game day, as one more block after the mod's shops.json blocks for that shop. true opens it, false shuts it, nil clears it. It is set at the call, with no queue, no daily cap and no command_finished, and applies from the next frame and is gone when the day changes or the game restarts. Only for a shop with open in the shop table, and refused when a mod later in the load order changes that shop. Needs scope world. ## Events - villager_talked: The player starts an ordinary talk with a villager. Return where your words go in it: nil to stay quiet, a talk table { place, line, topics, ask }, or a list of talk tables, one a place. Every line names its place: a plain string is refused and logged, with nothing said. place is "before" (ahead of the hello), "hello" (instead of an everyday hello; a hello with news is kept), "topic" (instead of the topic the game picks when the player chats, if it is one of topics, small_talk when you name none, "any" for all), "after" (after the topic, before a chat ends) or "conversation" (the whole talk: no hello, no menu, no topic). line is a page of 1 to 400 bytes or a list of 1 to 8 pages. ask = { text, choices } (2 to 4 answers) goes only with "conversation": its last page asks the question, and the player's pick goes to villager_answered. Every mod's handler is called, in load order. The first line returned for a place takes it; a later one for that place is logged and not said. A conversation needs every place free and ends the event. Lines are said only when that part of the talk comes: topic and after only when the player chats. A table that is not right is logged and nothing of it is said. Special talks never reach mods. These are a first meeting, a villager moving out, one with an errand, delivery or contest going with you, a complaint, a pitfall or a bee chase, an islander, Kamakura and summer camp. No handler is called for a special talk. The villager's next ordinary talk calls it as usual, so a line a script is keeping for "the next talk" waits for that one. - day_started: A new day begins in the game. It fires once per day, also when the game starts on a new day. It does not fire again when the game restarts later on a day the town already saw, because the save holds the day it last began. If the game was not saved since that day began, the save still holds the day before, so the next start fires it again. Count days by storing the last date you saw, not by counting calls. Its handler sees the whole day, the first day of a session included: game.calendar_today() lists today's calendar days, game.town() has the date, and game.player() and store.player have the player. A command queued here is applied once the player is free in the town. - item_picked_up: The player got an item. They picked it up, outdoors or off a room's floor, caught it with the net or the rod, or dug it up with the shovel. It fires once the item is in their pockets, or in the wallet for Bells. It does not fire for anything bought. A fish or a bug that goes into the pockets fires this event and then fish_caught or bug_caught, so a script that counts both counts that catch twice. It does not fire when the pockets were full. Outdoors the game then offers to swap the item for one in the pockets, and no event is sent whatever the player chooses. Indoors a full pocket refuses the pickup. - scene_entered: A scene starts, such as the town, a house or a shop. Not in the title demo, at player select or in the intro (the rule own_game_only). - data_migrated: Fires once per town, when mod.json "data_version" differs from the version the town's data was written at. It runs as the town loads, before any other event's handlers run in that town. from is 0 for data from before data_version. If the handler errors, the script stops and the version stays, so the next start tries again. Migrations run in load order. A remote.call from a data_migrated handler into a mod whose own data_migrated has not run in that town yet is refused. Needs data_version. - hour_changed: The game's clock reached a new hour. This is the game's own hourly update, midnight included. - item_bought: The player bought a good for Bells at any counter in the game. It fires as the seller takes the price. shop says which counter: "nook" (Nook's in every size, The City's Nookington's too), "flower" (the flower shop), "redd" (Crazy Redd), "saharah" (her carpet, swapped for one of yours and Bells), "joan" (turnips), "fireworks" (the fireworks show's stall), "shrine" (the New Year fortune slip), "gyroid" (what another player put up at their gyroid) or "villager" (a villager selling you something). Test e.shop == "nook" to keep to Nook's. price is the Bells paid. ordered is true for a Nook's catalog order, which is paid now and mailed tomorrow, so it is not in the pockets yet. Only Nook's and the flower shop sell mod items. A visitor buying in a friend's town gets a plain piece, so mod_item is nil there. Paid services that hand over no good are not purchases and do not fire it. These are the barber, Katrina, the Dream Suite and an Able Sisters design. - item_sold: The player sold for Bells. It fires once the wallet is credited. shop says to whom: "nook" (Nook's in every size, The City's Nookington's too) or "villager" (a villager buying something from your pockets). Nobody else in the game buys. item is the first good, count is how many went and bells is what they fetched. mod_item is the first good's full id when it is a mod item. What another player buys at your gyroid does not fire it. The gyroid hands you the takings later as one sum, with no record of what sold. - fish_caught: A fish was landed. pocketed says whether it went into the pockets. There is no size or length, because the game keeps none for a caught fish. Each kind has one fixed shadow size. Only the fishing tourney makes up a length, when the fish is shown to its host. When pocketed is true, item_picked_up fired for the same catch just before this event. - bug_caught: A bug was netted. pocketed says whether it went into the pockets. When pocketed is true, item_picked_up fired for the same catch just before this event. - letter_read: The player chose Read on a letter. item is the present, nil when the letter carries none. letter names the letters file letter it is, when a mod sent it. - villager_moved_in: A villager with no house was given one. It fires at the game start after a move-in. A brand-new town fires it for its first villagers. - visitor_arrived: A friend is riding into this player's own town. This is a friend visit, on the host's side. kind is "friend". - command_finished: A command this mod queued was applied or refused. When applied, ok is true and via says how (mailbox, post_office, pockets, mail, shown, taken, saved, set, unchanged or played). When refused, ok is false, with a code (command_codes) and a message. Sent only to that mod. - question_answered: The player answered this mod's ask, or closed it. choice counts from 1 and text is the answer picked. Both are nil when the window closed with no pick. Sent only to that mod. - timer_fired: A timer this mod set with timer.after is due. It fires once, at the end of a frame's update, in whatever scene the player is in, and the timer is gone before the handler runs. It is an event like any other. Its handlers share one instruction budget, it waits for a later frame when the frame's time is spent, and the commands it queues count against the per-event and per-day caps. At most one timer per mod fires in a frame. A timer that came due while the game was closed fires soon after the town loads. Sent only to that mod. - villager_answered: The player answered the question this mod's conversation asked (villager_talked returned place = "conversation" with an ask). Sent only to that mod, while the window waits. Return what the villager says next, in the same conversation: a line, or { line, ask } to ask again. Return nil and the talk ends. A reply that is not right is logged and the talk ends. ## Rules - shops_need_world: content.shops requires scope world. - shop_fields: 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. - unknown_keys: 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 : unknown key "", followed by (did you mean ""?) when a known key is close. $schema is known wherever a file may carry it. Keys are case-sensitive. - json_strict: Duplicate keys and \u0000 are refused in every JSON file. - extensions: A mod may hold only these file types (case-insensitive). - repo_files: 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. - frame_cap: 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. - data_migrated_needs_data_version: scripts.events may list data_migrated only with a data_version. - depends_not_conflicts: A mod id may be in only one of depends, optional_depends and conflicts. None of them may name the mod itself. - settings_world_hash: 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 +. 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. - visit_scope: 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. - visit_scope_content: 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. - world_scope: 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. - load_order_last_wins: 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_...__) beats any mod's every-palette file (tex1_..._$_) 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. - load_order_first_wins: 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. - dev_reload_hot: 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". - dev_reload_restart: 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. - visit_lend: 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. - city_set: 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. - calendar_board_world: A calendar file with a board notice requires scope world. The board is the town's, and a visitor reads it. - calendar_letter_once: 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. - font_characters: 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_need_scripts: permissions requires scripts, because only a script can use a command. - exports_need_scripts: exports requires scripts, because only a script offers functions. - own_game_only: 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. - commands_between_frames: 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. - commands_host_only: 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. - command_items: 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. - ids_are_numbers: 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". - settings_scope: 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. - optional_depends_order: 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. - optional_depends_cycle: 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. ## Limits - zip.bytes: The largest mod ZIP, compressed. - zip.unpacked_bytes: What every file in one mod adds up to, unpacked. - zip.files: The most files one mod may hold. Folder entries and repository files (rule repo_files: hidden names starting with a dot, __MACOSX, Thumbs.db, node_modules, and at the top README.md, CHANGELOG.md, LICENSE and the media folder) are dropped first and not counted. - zip.path_bytes: The longest path inside a mod, after the one top folder is stripped. ASCII only. - file.manifest_bytes: The largest mod.json. - file.json_bytes: The largest .json file other than mod.json. - file.lua_bytes: The largest .lua file. - json.depth: How deep JSON may nest. The top value is depth 0, and nothing may sit deeper than 32. - mods.enabled: The most mods switched on at once. - mods.enabled_unpacked_bytes: Every switched-on mod together, unpacked, on a computer. - mods.enabled_unpacked_bytes_phone: Every switched-on mod together, unpacked, on a phone or a low-memory device. - messages.lines: The most lines in one mod's messages file. - messages.key_bytes: The longest line key. - messages.text_bytes: The longest line, in UTF-8 bytes. Lines wrap by width, not by a count of characters. A row holds 180 pixels of the game's font, which is about 24 letters. Narrow letters like i and l take less room, and wide ones like W and m take more. A page holds 4 rows. - shops.stock: The most goods in one block for the flower shop: one per bench spot. - shops.blocks: The most blocks in the list one shop takes in shops.json. - shops.lines: The most lines in one slot of a block's "lines". The keeper says one of them each time. - shops.percent_max: The highest price_percent or buy_back_percent. - shops.name_chars: The longest shop name (the flower shop's door sign), in Unicode code points. - shops.line_chars: The longest shop line (a slot of "lines"), in Unicode code points. - shops.line_newlines: The most line breaks in one shop line. - shops.price_max: The highest price a mod shop may ask. The game raises a price below its own buy-back to the buy-back. The buy-back is what Nook pays for the item. - lua.memory_bytes: Memory one mod's script may use. Over it, the script stops for the session. - lua.memory_total_bytes: Memory every mod's script together may use. - lua.budget: Instructions one mod may run per event, counting all its handlers for that event together. The main chunk gets its own count. Library work is charged too: every 64 bytes allocated, every 4 pattern-matching steps and every element a table function touches. An allocation the memory limit refuses is charged too: one instruction for every 64 bytes the script holds. Over the limit, the script stops for the session. - lua.deadline_ms: Wall-clock backstop on a script's main chunk, for time the instruction count cannot see: one long call into C, or a garbage collection. The instruction budget is what stops a main chunk that does too much. On a slow device it is stretched by the device's pace (lua.pace_frame_ms). - lua.handlers_per_event: The most handlers one mod may register for one event. - lua.log_per_event: Mod log lines kept per event for one mod: its log() lines and the refusals written when it called cmd.* or timer.*. The rest are dropped, and the log says so once. - lua.log_per_session: Mod log lines kept per mod per session: log() lines and every refusal of its commands and timers. A script stop is always written. - store.bytes: The whole store of one mod in one town, store.player's values included. The whole store.client of one mod has the same limit. A set that would go over is refused and changes nothing. - store.key_bytes: The longest store key. - store.value_bytes: The longest string a store value may be. - items.per_mod: Items in one mod's items file. - items.total: Mod items across every switched-on mod. - items.renames: Entries in one mod.json "renames". - items.texture_files: Pictures in one mod item's own textures folder (its "textures" setting), counting the files in its subfolders. - lua.event_deadline_ms: Wall-clock backstop on one event run, for time the instruction count cannot see: one long call into C, or a garbage collection. The instruction budget is what stops an event run that does too much, and it counts the same on every device. On a slow device it is stretched by the device's pace (lua.pace_frame_ms). A busy device does not stop a mod that stays inside its budget. - lua.frame_budget_ms: Lua time all mods together get per frame. Once it is spent, every game event without an answer waits for the next frame, and villager_talked is skipped for the rest of that frame. command_finished and question_answered always run. It never stops or strikes a mod. At least one waiting event runs each frame, so on a slow device events wait longer but still run. - lua.slow_run_ms: An event run longer than this is a strike. On a slow device it is stretched by the device's pace (lua.pace_frame_ms). - lua.slow_runs: Strikes in a row before the script is stopped ("kept the game waiting"). A run under the limit clears the strikes. - lua.pace_frame_ms: The game's own work per frame that counts as full speed. Mods' Lua time is left out of it. When the game's recent frames take longer (a slow phone, a busy machine), the wall-clock limits are stretched. The stretch is recent frame work divided by this, from 1 up to lua.pace_stretch_max. It applies to lua.deadline_ms, lua.event_deadline_ms and lua.slow_run_ms. The frame cap and the instruction budget are never stretched. - lua.pace_stretch_max: The most a slow device stretches the wall-clock limits. At this stretch an event run's backstop is 1 second and a strike is a run over 64 ms. - lua.deferred_events: Events waiting for a later frame. Past that, an event is dropped and logged. - textures.label_chars: The longest label before a texture name in a mod, as in bookshelf-top_tex1_32x32_626709d910129694_$_8.png. A label is lowercase letters, digits and dashes, then one underscore. - textures.png_side: The longest side of a PNG texture. - textures.png_decoded_bytes: Decoded pixels of every mod's PNG textures together, on a computer. A PNG past it is left out and named on its mod's row. - textures.png_decoded_bytes_phone: The same on a phone or low-memory device. - textures.dds_bytes: Image bytes of every mod's DDS textures together on a computer, as the graphics card holds them. Only the first mip level counts: 1 byte a pixel for BC7 and DXT5, half a byte for DXT1 and 4 bytes uncompressed. A DDS past the limit is left out and named on its mod's row. The HD pack does not count. - textures.dds_bytes_phone: The same on a phone or low-memory device. - settings.per_mod: Settings one mod declares. - depends.per_mod: Mods in depends, in optional_depends and in conflicts, each. - data_version.max: The largest data_version. - store.towns: Towns whose mod data one browser keeps. Writing a 17th drops the file of the least recently written other town. - remote.copy_bytes: Data a remote.call copies each way. - remote.functions: Functions one mod offers with remote.add. - exports.per_mod: Remote functions one mod.json "exports" lists. It is also the most that remote.add offers. - exports.description_chars: One "exports" description, on one line. - nook.stock: The most goods in one block for Nook's store. - visitors.stock: The most goods in one block for a visiting seller (Crazy Redd, Saharah, the fireworks stall). - letters.per_file: Letters in one letters file. - letters.header_chars: A letter header, not counting {player}. - letters.body_chars: A letter body or a board notice. - letters.body_lines: Lines on the letter paper or a board page. - letters.footer_chars: A letter footer. - letters.sender_chars: A letter's name in the mailbox list. It is the letter's optional sender. Without a sender, it is the footer's first 8 characters. - calendar.per_file: Days in one calendar file. - talk.pools: Pools in one talk file. - talk.lines_per_pool: Lines in one pool. - talk.line_chars: A page of a villager line (a pool's or a script's), in Unicode code points. It may have at most 3 line breaks. A line that is one string is one page, wrapped to as many windows as it needs. - commands.per_event: Commands one mod may queue in one event. - commands.waiting: Commands waiting, all mods together. - commands.waiting_per_mod: Commands one mod may have waiting. - commands.letters_per_day: send_letter per mod per game day in each town. The count is per town and shared by its residents, not per player. It is a safety limit, not a game rule. A command counts when the game applies it, and the count is kept across a reload. A command lost with a closed tab before then never counts. The limit check adds the commands still waiting. A command refused for where the player is (The City, a visit) does not count. - commands.items_per_day: give_item per mod per game day in each town. The count is per town and shared by its residents, not per player. It is a safety limit, not a game rule. - commands.lines_per_day: show_line per mod per game day in each town. One that cannot be drawn (command-not-shown) does not count. The count is per town and shared by its residents, not per player. It is a safety limit, not a game rule. - commands.asks_per_day: ask per mod per game day in each town. One that cannot be drawn (command-not-shown) does not count. The count is per town and shared by its residents, not per player. It is a safety limit, not a game rule. - commands.take_items_per_day: take_item per mod per game day in each town. A take counts when its question is shown, whatever the player answers. One that cannot be drawn (command-not-shown) does not count. The count is per town and shared by its residents, not per player. It is a safety limit, not a game rule. - commands.take_bells_per_day: take_bells per mod per game day in each town. A take counts when its question is shown, whatever the player answers. One that cannot be drawn (command-not-shown) does not count. The count is per town and shared by its residents, not per player. It is a safety limit, not a game rule. - commands.take_item_count: The most pieces of one item a single take_item may ask for. It is the number of pockets. - commands.take_bells_amount: The most Bells a single take_bells may ask for. It is the most a wallet holds. - timers.per_mod: The most timers one mod may have waiting in one town. - timers.minutes_max: The longest a timer may wait, in game minutes. It is 7 game days. A timer never waits longer than this from any moment, so a clock set back cannot strand one. - timers.name_bytes: The longest timer name. A name is letters, digits, _, - and . only. - timers.data_bytes: The longest text a timer's data may be. - commands.letter_chars: A letter's text. It must also fit the letter's 6 lines of 192 pixels. - commands.letter_from_chars: A letter's signature, also the mailbox list's sender. It is one line. A line break or another control character is refused. - commands.line_bytes: A show_line text. - commands.ask_chars: An ask question. - commands.choice_chars: One answer of an ask. - commands.choices_min: The fewest answers an ask may offer. - commands.choices_max: The most answers an ask may offer. - commands.papers: Letter papers, numbered 0 to 63. - calendar.board_per_day: Board notices that go up on one day across every mod. The first ones in load order go up. On a full board, a mod notice first takes the place of an earlier day's mod notice. It never pushes off a page dated today. - store.towns_bytes: What every town's mod data in one browser adds up to. Writing past it drops the least recently written other towns' files first. Mod data therefore never pushes a save over the cloud's 5 MB. - talk.line_newlines: The most line breaks in a page of a villager line (a pool's or a script's). - talk.pages: Pages in one villager line, when the line is a list of pages (a pool line, or a line a script returns). Each page starts on a clean window. - talk.villager_chars: A pool's "villager" name, as the game spells it. - items.price_max: The highest price an item in a mod's items file may have. - manifest.name_chars: The longest mod "name", in Unicode code points, spaces at the ends not counted. - manifest.authors: The most names in "authors". - manifest.author_chars: The longest name in "authors", spaces at the ends not counted. - manifest.description_chars: The longest "description". - manifest.tags: The most different tags in "tags". - settings.label_chars: A setting's "label", spaces at the ends not counted. - settings.description_chars: A setting's "description". - settings.choices_min: The fewest "choices" a choice setting lists. - settings.choices: The most "choices" a choice setting lists. - settings.choice_chars: One choice of a choice setting, on one line. - settings.text_chars: The largest "max_length" a text setting may ask for. - settings.number_max: A number setting's "min" and "max" lie within minus this and this. - depends.range_bytes: The longest version range in depends or conflicts. - depends.range_parts: The most comparisons in one version range, like ">=1.0.0 <2.0.0" (two). --- ## Page: https://playaconline.com/modding/cli/ ## The playac-mod tool playac-mod is a command line tool. It checks a mod with the game's own rules, packs the ZIP, and reloads your mod in the game as you save. You do not need it to make a mod. Installing a ZIP in the Mods tab runs the same checks. It saves time once you write scripts or make more than one mod. Start a mod from an example or a starter kit. Share it from the site, see Publishing. ## Install it You need Node.js 18.17 or newer. Run node --version to see which you have. If you have none, see Set up your computer. terminal: ``` npm install -g https://github.com/Play-AC-Online/playac-mods/releases/download/cli-v1.1.0/playac-mod-1.1.0.tgz ``` This installs release 1.1.0 of the tool from its GitHub release in playac-mods. The SHA-256 of that file is: SHA-256: ``` ffb77f79497d4afe999fbaa3a3b9912c165c728a40008108b0339549ed1a5560 ``` To check it yourself, download the file, compare its SHA-256 and install the file you checked: terminal: ``` curl -fLO https://github.com/Play-AC-Online/playac-mods/releases/download/cli-v1.1.0/playac-mod-1.1.0.tgz shasum -a 256 playac-mod-1.1.0.tgz # macOS, Linux certutil -hashfile playac-mod-1.1.0.tgz SHA256 # Windows npm install -g ./playac-mod-1.1.0.tgz ``` A package named playac-mod on the npm registry is not the game's. Do not install the tool by its name alone. Check that it worked: terminal: ``` playac-mod --version playac-mod help ``` ## If the install fails What you see | What to do EACCES: permission denied (macOS, Linux) | Node.js was installed for the whole computer. Install Node.js with nvm, then run the install line again (how). Putting sudo in front also works, but every later update needs it too. playac-mod: command not found, or "not recognized" | Open a new terminal window. If it is still missing, run the install line again. "running scripts is disabled on this system" (Windows PowerShell) | Use Command Prompt, or run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once. npm error 404 naming registry.npmjs.org/playac-mod | Something asked the npm registry for the tool by its name. Use the install line above. playac-mod needs Node.js 18.17 or newer | Your Node.js is too old. Install the current LTS and open a new terminal. Two setup guides cover more causes, step by step for macOS, Windows and Linux. They are Node.js and the playac-mod tool and Troubleshooting. ## Commands Every command works on the current folder unless you name another. playac-mod help prints this list, and playac-mod --help prints one command's options. Command | What it does check | List every problem the game would find. pack | Write the mod's ZIP. dev | Serve the folder to the game and reload on edits. ## check terminal: ``` playac-mod check [folder | file.zip] [options] ``` Applies the game's rules and lists problems per file. Lua syntax is checked by the game's own parser. Argument or option | What it does [folder | file.zip] | A mod's folder or a mod ZIP. Default: the current folder. --verbose | Also list the files pack leaves out. --json | Print the result as JSON. --no-lua | Skip the Lua syntax check. terminal: ``` playac-mod check playac-mod check ../yourname.my-mod-1.0.0.zip ``` ## pack terminal: ``` playac-mod pack [folder] [options] ``` Checks the mod, then writes -.zip beside the folder. The same files always give the same ZIP. Argument or option | What it does [folder] | The mod's folder. Default: the current folder. --out | Write the ZIP here instead. --json | Print the result as JSON. --no-lua | Skip the Lua syntax check. terminal: ``` playac-mod pack ``` ## dev terminal: ``` playac-mod dev [folder] [options] ``` Open the game with ?moddev=1, go to Settings, Mods, Developer, Load a mod you are making, press Connect, then Restart now once. It prints a line when the game connects, loads the mod, reloads a file, and disconnects. Listens on this computer only. Ctrl+C stops it. Argument or option | What it does [folder] | The mod's folder. Default: the current folder. --port | Port to listen on. Default: 2604, or the next free one. --origin ... | Also allow a game page at this address. --no-lua | Skip the Lua syntax check. terminal: ``` playac-mod dev ``` ## Options every command takes --help | Show the command's options. Short: -h. --version | Print the version. Short: -v. An option a command does not have is refused by name. Nothing runs. ## Exit codes Code | Meaning 0 | It worked. 1 | The mod has problems. 2 | The command line was wrong. check --json and pack --json print JSON for other tools. check prints each problem with its file and a link to its page in Errors. ## Versions and updates playac-mod --version prints the version and the build, like playac-mod 1.1.0, build 1a2b3c4d5e6f. A version is three numbers. The middle one goes up when the rules, the API level or a command changes. The last one goes up for fixes. A release never changes after it is listed. The release list gives every release with its SHA-256. Each release is a file of a GitHub release of the public playac-mods repository. To update, run the install line of the newest release. The tool does not check for one itself. Editor types for scripts are one file, api/playac.lua in the public repository. See Set up your computer. ## Changelog This is the tool's own changelog. The API changelog lists what each API level holds. ## Source The tool's source is in the cli folder of the public repository, under the MIT licence. Report a bug in it there. --- ## Page: https://playaconline.com/modding/concepts/ ## How mods work The ideas every mod shares. ## A mod is a ZIP A mod is a ZIP file with a mod.json in it. A typical one looks like this: my-mod.zip: ``` my-mod.zip ├── mod.json required ├── textures/ .dds pictures (texture mods) ├── messages.json lines, by key ├── shops.json shops, by shop id (World mods) └── main.lua a script ``` - mod.json sits at the top of the ZIP, or inside one folder at the top. The game ignores that folder, so zipping a folder works. - A mod holds only .json, .lua, .dds, .png, .txt and .md files. Any other kind is refused. - File and folder names use plain ASCII letters, digits and punctuation. A name cannot contain \ or :, and a folder cannot be named . or ... - Two names that differ only in upper and lower case are refused. - The game ignores a mod repository's own files in any ZIP: hidden files and folders (a name starting with a dot, such as .git, .github, .gitignore, .vscode, .playac and .DS_Store), __MACOSX, Thumbs.db and node_modules anywhere, and at the top of the mod README.md, CHANGELOG.md, LICENSE or LICENCE with any extension and the media/ folder. It drops them before it checks anything, keeps none of them and counts none toward a limit. So a Finder or Explorer ZIP of a whole mod repository works as it is. - A JSON file that has the same key twice is refused. ## mod.json This example has every field: mod.json: ```json { "schema": 1, "api": 1, "id": "yourname.my-mod", "name": "My Mod", "version": "1.0.0", "authors": ["yourname"], "description": "What it does.", "scope": "client", "content": { "textures": "textures/", "messages": "messages.json" }, "scripts": { "main": "main.lua", "events": ["villager_talked", "day_started"] }, "assets_original": true } ``` Field | Required | Rule schema | yes | Always 1. api | yes | The API level the mod is made for. It is a whole number, and it is 1. See API levels. id | yes | Your name, a dot, the mod's name. See ids. name | yes | 1 to 60 characters. Shown in the Mods tab and the mod list. version | yes | Three whole numbers with dots, like 1.0.0 or 2.13.4. A leading zero is refused, so 1.02.0 does not work. authors | yes | A list of 1 to 8 names, each 1 to 40 characters. description | no | Up to 500 characters. tags | no | Up to 5 different tags. Players filter the mod list by them, and the game never reads them. The tags are textures, clothing, furniture, scenery, villagers, dialogue, shops, seasonal, holidays, quality-of-life, humor, accessibility and scripts. Anything else is refused. scope | yes | "client" or "world". See scope. content | no | Any of "textures", "messages", "shops", "items", "letters", "calendar" and "talk". textures is a folder with at least one file. The others are files. messages is one .json file. Each path must be in the ZIP. Any other key is refused. scripts | no | main is a .lua file in the ZIP. events lists one or more events, each once: villager_talked, day_started, item_picked_up, scene_entered, data_migrated, hour_changed, item_bought, item_sold, fish_caught, bug_caught, letter_read, villager_moved_in, visitor_arrived, command_finished, question_answered, timer_fired, villager_answered, button_pressed, button_released and player_acted. Nothing else goes inside scripts. permissions | no | 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. exports | no | 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. renames | no | 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. depends | no | 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_depends | no | 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. conflicts | no | 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_version | no | 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. settings | no | 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. assets_original | yes | Must be true. It is your promise that every file is your own work. - "game" and "save" are reserved. A mod.json with either is refused, even when the value is null. - A key the game does not know is refused, and the message names the closest key: mod.json: unknown key "permisions" (did you mean "permissions"?). - The shops, items, letters, calendar and talk files refuse unknown keys the same way. A messages file does not, because every key there is a line. - A "$schema" line for your editor is a known key. - Keys are case-sensitive. Name is not name. ## Ids and namespaces - An id is author.mod-name. Each part uses lower case letters, digits and dashes, and starts with a letter or digit. The part before the dot has up to 32 characters, and the part after has up to 48. - The id is how the game tells mods apart. Installing a ZIP with an id you already have replaces that mod and keeps its place in the list. - Your lines are named id:key, such as sam.gossip:line1, so two mods never clash over a key. - The mod list keeps the author names playaconline, official, admin and example for the site. You can use them at home, but an upload with one is refused. - The first account to share an id owns it. Only that account can share new versions of it. ## Scope A Just you mod ("scope": "client") changes the game only for the player who installed it. A World mod ("scope": "world") changes the town, so visitors see it too. | Just you mod, "client" | World mod, "world" Who sees it | Only the player who installed it. | Anyone in the town, visitors too. Can hold | Everything except a shop, a bulletin board notice, a script that sets the weather or a script that changes a shop. | Everything. Only a World mod can hold a shop, a bulletin board notice, a script that sets the weather or a script that changes a shop. Friend visits | Never matter. | A World mod counts when it has textures, shops or items content. One with only lines, letters, calendar days, talk pools or a script does not count. Both towns need the same World mods that count, in the same versions and the same order. There is one exception. When every one of the host's is a reviewed version from the mod list, the visitor can load them for that visit. Every world setting of a World mod that counts is part of the match. A setting marked "scope": "client" is the player's own and is not. See world settings and client settings. In The City | Its textures, lines and scripts keep running. Its mod items are off, and every command is refused there. | Its shops, board notices and mod items switch off. Its textures, lines and scripts keep running, but every command is refused there. Use "client" unless your mod has a shop, a bulletin board notice, a script that sets the weather or a script that changes a shop. Those change the town a visitor sees, so a Just you mod with one is refused. See Multiplayer for the full visit rules. ## API levels and compatibility - The api number says which rules your mod was written for. The game runs level 1, and a mod says "api": 1. The changelog lists what the level holds. - When a change would break existing mods, we add a new level. Mods made for the old level keep working by the old level's rules while the game still supports it. - A mod for a level the game no longer runs is not loaded. Its row says made for an older game. - A mod for a newer level than the game knows is not loaded either. Its row says needs a newer game. Other mods are not affected. - A level is read for at least 12 months after the next level ships. - Before a feature goes, it is marked deprecated for at least two more levels and at least 90 days, whichever is later. The changelog says how to move your mod up. - We promise only what these docs and the reference describe. Anything else your mod finds by experiment may change without notice. ## When mods load - The game reads mods once, when it starts. Installing, removing, switching or reordering a mod needs a restart. The Mods tab offers Restart now. - A mod that cannot be read at start is skipped, and its row says why. The other mods still load. - If a mod stops the game from starting, choose Start without mods in the Mods tab. Adding ?nomods=1 to the end of the play page's address does the same. Either starts the game once with every mod off. - If the game stops responding while it starts with mods on, the next start runs once without them and names the mods that were on. If it stops responding later, during play, that takes two sessions in a row. Nothing is switched off for you. Reloading or closing the tab does not trigger it. - No mod runs in the title screen demo. ## Load order Mods load in the order the Mods tab lists them. The arrows on each row move it. The table says which mod wins when two mods change the same thing. Content | Two mods change the same thing A texture | The lower mod in the list wins, because it loads last. Any mod wins over the HD texture pack. A shop (the flower shop, Nook's, any shop id) | The lower mod in the list wins that shop whole, because it loads last. Two mods that change different shops both apply. A place in a villager talk (a script's villager_talked) | The highest mod whose script returns a line for that place takes it. A conversation takes the whole talk, and mods below it are not asked. command_finished, question_answered, data_migrated, timer_fired and villager_answered | Each goes to one mod. A command's result and an answer go to the mod that asked. data_migrated goes to the mod whose data version moved. timer_fired goes to the mod that set the timer. villager_answered goes to the mod whose conversation asked. Every other event (14 of them) | Every mod's handlers run, top to bottom. - A texture or a shop has one slot. Each mod writes over the mod above it, so the lowest mod in the list wins. Nook's stock follows the same rule. - For a script's talk lines, the game asks each mod in turn, and the first line for each place takes it. The highest mod wins a place. - Move a mod down to make its shop win. Move it up to make its script's lines win. - Talk pools are not ranked. They fill the places no script took, and one line is picked from every mod's fitting lines for that place. ## Limits Sizes here are binary. 1 MB is 1,048,576 bytes and 1 KB is 1,024 bytes. What | Limit Files in a mod | 2000 ZIP size | 16 MB Unpacked size of a mod | 64 MB mod.json | 64 KB Any other .json | 256 KB Any .lua | 512 KB A file path inside the mod | 160 bytes, ASCII Mods switched on at once | 32 Unpacked size of all switched-on mods | 96 MB on a computer, 24 MB on a phone or low-memory device A .png | 2048 x 2048 pixels A .dds | Up to 16384 pixels a side, one level (no mipmaps) Message keys | 256 per messages file, each 1 to 48 of a-z 0-9 _ . - A line | 1 to 400 bytes. The game shows 24 characters a line and 4 lines a page. Shop name | 1 to 40 characters, one line Shop line (a greeting, a stock line) | 1 to 160 characters, at most 3 line breaks; a slot holds 1 to 8 lines Shop blocks | 1 to 8 for one shop Shop goods in a block | 1 to 6 at the flower shop, 1 to 16 at Nook's, 1 to 6 at a visiting seller. A price is 1 to 99999 Bells. Script memory | 4 MB per mod, 16 MB for all mods together Script time | 200,000 Lua instructions per mod per event. Library work counts too. That count is what stops a script, the same on every device. Wall-clock time is a backstop: one event run past 125 ms, or 3 runs in a row over 8 ms, also stop it, and a slow device stretches both. The main chunk at start has a 250 ms backstop. Handlers | 16 per event per mod log() | 20 lines per event, 500 per session store | 8 KB per town, and 8 KB in store.client. A key is up to 64 bytes and a text value up to 1024 bytes. Commands | 4 per event. Each game day, per mod in each town: 3 letters, 5 items, 20 lines and 10 questions. The day limit is per town, for all of its residents together. New items | 64 per mod, 512 across all mods Settings, dependencies | 16 settings, 16 depends per mod A talk line from a script | Up to 400 bytes Uploads | 5 an hour, 10 waiting for review at once, 64 MB stored per account ## Saved data - Each mod has a store per town. It holds text, numbers and true/false values under keys, up to 8 KB per town. - The store travels with the town. It is in the cloud save, in backups and in Export with mod data under the save button's More options. - A town has up to 4 residents, and they share store. store.player is per mod, per town and per player, inside the same 8 KB. - store.client belongs to the browser, whatever town is loaded. - Every store.set, store.player.set and store.client.set writes the mod's file in the save folder before it returns. - The browser keeps the save folder at the game's next save sync. That happens at a game save. For the cloud, mod data also uploads at most every 2 minutes. A tab closed before the sync loses the last sets. - Whole numbers come back as whole numbers. - A store.set that would go over 8 KB changes nothing and raises an error. So does a key or value over its limit. Unless you call it inside pcall, that error stops your script. - Removing a mod asks the player whether to keep its data or delete it. See Per-town data. ## The safety model Players install mods from strangers. So a mod can do much less than code in a normal program. - Scripts have no io, os, debug or package libraries. They have no load, dofile, loadfile, require, collectgarbage or print. A script cannot read files, use the network or load more code. - Scripts are read as text only. Compiled Lua bytecode is refused. - Each mod's script runs in its own Lua state, under memory and time limits. A script that goes over is stopped for the session, and the rest of the game carries on. - Scripts answer events with data. A script cannot change the game from inside an event. A command (cmd.*) only queues a change. - The game applies queued commands at the end of a frame's update, before the frame is drawn, while the player is free. So a mod cannot corrupt a save in the middle of a frame. - Mods never patch the game's code or read its memory, and never will. - Mods live in the player's browser storage and are read once at start. A mod cannot see the player's account, files or anything else on the page. - A moderator reviews every version of every shared mod, pictures included, before it is listed. A mod installed from a file is never uploaded, so nobody has reviewed it. - The game checks its mods against the mod list at every start. A removed version is switched off for everyone who has it at their next check. - The check never holds the game up for long. When the game is offline or the check is too slow, the game goes by the last check in that browser. A version that was removed stays off, and so do all mods if mods were switched off for everyone. A mod the game has no word on runs as before, so offline play keeps working. ## The life of a shared version Each version you share moves through these states: State | In the mod list | New installs | Copies already installed Waiting for review | No | No | Only you have it Listed | Yes | Yes | Run Older version (a newer version is listed) | No, the newer one is | No | Run, and show Update available Withdrawn (by you or a moderator) | No | No | Run, and say it was withdrawn. Friends who both have it can still visit each other. A version you withdrew yourself can still be lent to a friend for a visit. A version a moderator withdrew cannot. Removed | No | No | Switched off at the next start, with the reason. Offline, it stays off. We delete its files from the site, except as evidence for a child-safety report. Refused | No | No | Not applicable. We delete its files from the site. - A version number cannot be reused once it is waiting, listed or removed. Share a fix as a higher version. - A refused version may be fixed and shared again under the same number. - A removal also switches off the same files installed from a ZIP, because the game matches mods by their contents. - You can withdraw a version yourself under Share a mod in the Mods tab. See Publishing, withdraw a version. - A withdrawn or older version stays downloadable at /api/mods/blob/. That address never changes. - /api/mods/by-content/ finds a version from the content hash a friend visit reports. Publishing covers each step and the reasons a moderator can give. --- ## Page: https://playaconline.com/modding/cookbook/ ## Cookbook These are complete, working mods, shown file by file. Each one is its own public repository on GitHub. We install and play each one in our own tests, so it works with the current game. Copy any of it into your own mod. Mods whose id starts with example. are ours. To build on one, copy its files and give the copy your own id, such as yourname.something. The example name cannot be used for a shared mod. ## How do I... Each common task, and the file that does it in an example mod, a starter kit or a recipe further down this page. A link opens the file on GitHub at the line it starts on. How do I... | Where | API ## Recipes There are 4 example mods. Each shows two kinds of mod working together in one mod. Mod | Kind | Repository Springtime Town | Textures and villager lines, no code | playac-example-springtime-town After Hours | Nook's at night, an item with its own pictures | playac-example-after-hours Harvest Post | Calendar days, letters, a script with commands and a timer | playac-example-harvest-post Button Tricks | Buttons, looks, weather, reactions and saves | playac-example-button-tricks ## Springtime Town Town grass with clover and tiny white flowers, and new small talk from each villager in their own personality's voice, some of it for the season, the time of day or the weather. Textures and data only, no script. Kind: Textures and villager lines, no code. Shows: . Id: example.springtime-town, version 1.0.0, API level 1. Repository: github.com/Play-AC-Online/playac-example-springtime-town. This page shows its files at tag v1.0.0. In GitHub source form that version is: GitHub source: ``` github.com/Play-AC-Online/playac-example-springtime-town@v1.0.0 ``` Video: Download Springtime Town as a ZIP, ready to install. It downloads from the example's release on GitHub. The files are in the Example mods section of this text. ## After Hours From 1 AM to 3 AM the town shop opens again, and all it sells is gyroids. A different few stand on the floor each night, and among them, now and then, a Ghost Lantern of the mod's own, its windows glowing green. Every other spot is empty. The rest of the day the shop is its usual self. Remove the mod and a Ghost Lantern you bought stays in your house as the plain tall lantern it is built on. Kind: Nook's at night, an item with its own pictures. Shows: . Id: example.after-hours, version 1.0.0, API level 1. Repository: github.com/Play-AC-Online/playac-example-after-hours. This page shows its files at tag v1.0.0. In GitHub source form that version is: GitHub source: ``` github.com/Play-AC-Online/playac-example-after-hours@v1.0.0 ``` Video: Download After Hours as a ZIP, ready to install. It downloads from the example's release on GitHub. The files are in the Example mods section of this text. ## Harvest Post Two calendar days of our own, the Harvest Fair and Apple Day, with a notice on the bulletin board, villagers talking about it all day and a letter on Apple Day. On fair day you can enter the fruit contest for 100 Bells and get a thank-you letter. And once a game day, a script mails you a letter with a little present: a worked example of mod commands, a question, a setting and a timer. Kind: Calendar days, letters, a script with commands and a timer. Shows: . Id: example.harvest-post, version 1.0.0, API level 1. Repository: github.com/Play-AC-Online/playac-example-harvest-post. This page shows its files at tag v1.0.0. In GitHub source form that version is: GitHub source: ``` github.com/Play-AC-Online/playac-example-harvest-post@v1.0.0 ``` Video: Download Harvest Post as a ZIP, ready to install. It downloads from the example's release on GitHub. The files are in the Example mods section of this text. ## Button Tricks Tricks on the D-pad, anywhere in town. Right puts on a striped, spotted or checked hat and shirt of the mod's own. Left turns the weather to snow, then a blizzard, then clear again (rain and a storm in the rain season). Up dances, cheers or poses, and spins with R held. Down saves the town and tells you where you are. And every fifth thing you do, your character cheers. Kind: Buttons, looks, weather, reactions and saves. Shows: . Id: example.button-tricks, version 1.0.0, API level 1. Repository: github.com/Play-AC-Online/playac-example-button-tricks. This page shows its files at tag v1.0.0. In GitHub source form that version is: GitHub source: ``` github.com/Play-AC-Online/playac-example-button-tricks@v1.0.0 ``` Video: Download Button Tricks as a ZIP, ready to install. It downloads from the example's release on GitHub. The files are in the Example mods section of this text. ## More recipes Smaller mods for the rarer features, which no example mod uses. Each is a whole mod: put its files in a folder, change yourname to your own name, and it installs. ## Try a recipe - Download its ZIP above, or copy its files into a folder with the same names. - In the game, open Settings, then Mods. Under Install from a file, choose Choose a file, then Restart now. The example mods are also in the mod list, under Browse mods in the Mods tab. ## Start from a recipe on GitHub - Make a copy of the recipe's repository on GitHub, or download its ZIP and put the files in a new repository. - Change the id in mod.json to your own, such as yourname.something, and set your own name. - Tag a release named for the version in mod.json, such as v1.0.0. - In the game, open Settings, then Mods, and scroll to Share a mod. Import from GitHub shows there, under the upload form, once you are signed in, have answered the age question, have accepted the mod rules and have entered a code from your authenticator app. Paste github.com/you/your-repo@v1.0.0 there. See Publishing. --- ## Page: https://playaconline.com/modding/downloads/ ## Starter kits and downloads These are ready-made mods to start from. Each ZIP installs as it is, so you can see it working before you change it. To install one, open Settings, then Mods, and choose Install from a file. Every download here comes from GitHub, from the public repositories the files are made in. The links go straight to the file. ## Starter kits Unzip a kit, put your own name in its mod.json and follow its README.txt. Each kit also carries VS Code settings. The kits are files of a release of playac-mods, made from its templates folder. Kit | For | Inside The texture kit works as it is. It turns the town grass into a green check. To repaint other textures, find their names in the model viewer. Then save your pictures in the kit's textures/ folder under those names. The artist path has every step, and the Springtime Town example below is another texture mod to start from. The lines kit has no code. Its talk.json holds pools of lines for everyone, a personality or one villager, and the villagers say them as small talk when you choose to chat, or in another place in the talk. The script kit shows the other way, a line from Lua that depends on something: a villager notices an apple in your pockets. The Lines guide says which to use. ## Example mods The cookbook explains each one, file by file. Each is a public repository on GitHub, and each version is a release there with the mod's ZIP attached. - Springtime Town (Textures and villager lines, no code). Repository: playac-example-springtime-town, release v1.0.0. - After Hours (Nook's at night, an item with its own pictures). Repository: playac-example-after-hours, release v1.0.0. - Harvest Post (Calendar days, letters, a script with commands and a timer). Repository: playac-example-harvest-post, release v1.0.0. - Button Tricks (Buttons, looks, weather, reactions and saves). Repository: playac-example-button-tricks, release v1.0.0. ## Tools - JSON schemas. With a schema, your editor checks a file as you type: mod.schema.json (mod.json), shops.schema.json (shops.json (flower shop and Nook's)), messages.schema.json (a messages file, which cannot name its own schema, so map it in your editor), mod-items.schema.json (an items file), letters.schema.json (a letters file), calendar.schema.json (a calendar file), talk.schema.json (a talk pools file). A mod.json or shops.json can name its own with "$schema": "https://playaconline.com/schemas/mod.schema.json". The game ignores that key. - Lua type hints. playac.lua has every call and event, for VS Code's Lua extension (by sumneko). Add it to Lua.workspace.library. The public repository has the same file as api/playac.lua. - The item list. items.json has every item and piece of furniture, with its name, price, lowest price and which shop can stock it. The item reference shows the same list as a page. - The whole API as data. Download api.json. - The playac-mod tool. It needs Node.js 18.17 or newer. Its commands are check, dev and pack. Install the tool with npm install -g https://github.com/Play-AC-Online/playac-mods/releases/download/cli-v1.1.0/playac-mod-1.1.0.tgz. That is playac-mod-1.1.0.tgz, release 1.1.0, a file of a GitHub release of playac-mods. Its SHA-256 and every command are on The playac-mod tool. - Developer mode. It needs no download. Open the game with ?moddev=1. In Settings, Mods, choose your folder, or press Connect to reach playac-mod dev. Then restart once. See Testing. For AI assistants, get the AI pack, from the same release of playac-mods as the starter kits. Make mods with an AI assistant says how to use it. ## The public repository The public repository on GitHub holds every starter kit as plain folders, the API files, the setup guides and the tool's source. Its releases hold the kits' ZIPs, the AI pack and every release of the tool. Each example mod is its own repository. All of it is under the MIT licence, and a mod you make from a kit or an example is yours. --- ## Page: https://playaconline.com/modding/faq/ ## FAQ and troubleshooting The problems people hit most, and how to fix them. For a specific message, see the errors catalogue. ## My texture doesn't show - Did you restart after installing? Mods load only when the game starts. - Is the mod switched on in the Mods tab, with no red message under it? - Is the file name exactly the one the model viewer shows, ending .dds or .png? With one wrong letter in the tex1_... part the game never asks for the file. Use Save all or Copy name rather than typing it. - Is it a .png? It must be at most 2048 x 2048. All mods' PNGs together must be at most 96 MB of pixels (24 MB on a phone). The Mods tab names a PNG it left out. - Is it in the folder content.textures names in mod.json? - Is it saved with no mipmaps, as uncompressed RGBA, BC1, BC3 or BC7? The game skips a file it cannot read. BC7 needs a browser with BPTC support. Try uncompressed RGBA to rule that out. - Does the texture change with the season or time of day? It may be drawn under another palette, with another name. Use the $ name (Any palette) to cover them all. See palettes and seasons. - Is another mod lower in the list replacing the same texture? The lowest one wins. ## Where do I find a texture's name? You do not need to. In the model viewer, open the model, press Textures, then Save all. Every texture of the model comes already named. Paint over them and put them in your mod's textures/ folder. For one texture's exact name, pick it and press Copy name. The viewer also lists the town's ground and water, rooms and the train window, menus, effects and more. See the textures guide. ## My JSON file is refused JSON is strict. These are the usual slips: - A comma after the last item in a list or object. - A missing comma between two items. - Curly quotes (“ ”) from a word processor instead of straight quotes ("). - A quote mark inside a line not written as \". - The same key twice. a common mistake: ``` { "line1": "Hello!", "line2": "Bye!", <- the last line must not end in a comma } ``` A code editor such as VS Code underlines these as you type. ## My script stopped The Mods tab row says Script stopped: and why. A reason like yourname.my-mod/main.lua:12: attempt to index a nil value points at line 12. Reason | What happened | What to do script took too long | A handler did too much work in one event. | Prepare data when the script starts, not on every talk. See limits. script kept the game waiting | Too many event runs were slow, each one under the hard limit. | Do less per event, or spread the work over several events. out of memory | Your script holds more than 4 MB, or all mods together more than 16 MB. | Keep less data in tables. on(): '...' is not in this mod's "scripts.events" list in mod.json | The script handles an event that mod.json does not list. | Add that event to scripts.events in mod.json. on(): handlers can only be added while the script loads | The script called on() after it finished loading. | Move the on() call to the top level of your file. A store.set error | The store is over 8 KB, or a key or value is too long. | Store less. See the store. A stopped script stays stopped until the next start. After you fix it, install the ZIP again and restart. In developer mode, saving the fixed file starts it again with no restart. ## My villager line never appears - Every pool needs a place. A pool with "place": "topic" is a topic line for small talk, after the hello. Choose the chat answer, such as "Let's talk!", not the errand answer or "Never mind". The villager picks small talk only on some chats, so name more topics (or "any") to be heard more often, or use another place. A pool speaks in chance talks in 100 that it fits (every one if you leave it out). Check the pool's season, time, weather and day are the ones now. A new player's first ten chats are tips from the villagers, so topics start after those. - A hello line replaces only an everyday hello. A hello with news, such as a bee sting, is kept. - A pool for the villager by name, or for their personality, takes that place over the less specific pools. If it rolls no, the pools for everyone are not asked. - A script's line for a place another mod higher in the list already took is not said. The Mod log says so. - For a script, villager_talked must be in scripts.events, and your handler must return a non-empty string or a talk table with a place. - Only ordinary talks reach mods. A special talk never does. Talk to the villager again, and the next ordinary talk reaches your mod. - Special talks are a first meeting, a villager moving out, an errand, a delivery or a contest going with you, a complaint, a pitfall, a bee chase, an islander, Kamakura and summer camp. - A mod higher in the list may have answered first. Move yours up, or switch the other one off to test. - message("key") gives nil for a key your messages file does not have. Check the spelling, and check that content.messages names the file. ## My shop does not change - The mod must be a World mod ("scope": "world"). - Visit during your hours, and not between 2 AM and 7 AM. - In The City, a World mod's shops are switched off. - Goods the game cannot sell are left out and named on the mod's row. - Is a price higher than you set? The game raises a price below what Nook pays up to that amount. - A town fruit (apple, cherry, pear, peach, orange) is raised to 500. A coconut's lowest price is 150. ## My mod was skipped, or says "made for an older game" - This mod did not load gives the reason. Often a file it names is missing from the ZIP. - made for an older game means its "api" is missing, or below the oldest level this game still runs. The game runs level 1. Set "api": 1 and install it again. - needs a newer game means its "api" is above what this game knows. Reload the page to get the newest game, or lower the number. - All switched-on mods together can unpack to 96 MB on a computer and 24 MB on a phone. Over that, a new mod installs switched off and says so, and an update to a mod that is on is refused. Switch another mod off, or make yours smaller. ## A friend visit is refused - The message says your World mods don't match. Both towns need the same World mods that count for visits, in the same versions and order, or none. The multiplayer guide says which count. - Compare your Mods tabs. Or switch your World mods off for the visit and restart. - Just you mods never cause this. - If every World mod of the host that counts is a reviewed version from the mod list, the visitor is offered to load them for that visit instead. A mod installed from a file cannot be lent. ## My upload was refused - If it is refused straight away, the site names the rule and the file. - The common causes are a texture that is an unchanged copy of the game's or the HD pack's, a DDS with mipmaps, a reserved author name such as example, a version you already shared, someone else's id, and too many uploads in an hour. - If it is refused after review, its row in the list under Share a mod shows the reason, what it means and the moderator's note. Fix it and upload again. See review. ## The game will not start with my mod Choose Start without mods in the Mods tab, or open /play/?nomods=1. Then switch the mod off or remove it. ## Where are my mods kept? Will I lose them? - Mods are kept in your browser's storage on that device. - When you are signed in, your account also keeps the list of what you installed, with on or off, order and settings. Your other browsers and devices then offer to install the same mods. See other devices. - Only mods from the mod list download on another device. A ZIP you installed from a file is never uploaded, so install that file there yourself. - The game asks the browser to keep your mods. If the browser clears them anyway, the Mods tab tells you once. Keep your ZIPs. ## Can I make mods on a phone? You can install and test mods on a phone. Making them is easier on a computer, because you edit files and make ZIPs. The model viewer names textures on a phone too. --- ## Page: https://playaconline.com/modding/guides/commands/ ## Commands for letters, items, lines, questions and takes A script never changes the game while it runs. It queues a command. The game carries the command out at one safe point in each frame, after the game's update and before the frame is drawn. It waits until the player is free, which means not in a talk, a menu, a cutscene, a door or a scene change. The result comes back to your script as a command_finished event. ## Permissions List every command your script uses in mod.json "permissions". The game refuses any command the list leaves out. Players see the list on the Mods tab, for example "Can send you letters". A mod without the key can change nothing. mod.json: ```json { "schema": 1, "api": 1, "id": "yourname.daily-letter", "name": "Daily Letter", "version": "1.0.0", "authors": ["yourname"], "scope": "client", "scripts": { "main": "main.lua", "events": ["day_started", "command_finished"] }, "permissions": ["send_letter"], "assets_original": true } ``` ## The commands Command | Does cmd.send_letter{ text, item?, from?, paper? } | Puts a letter in the player's mailbox, with a present if you give one. When the mailbox is full, the post office keeps the letter, as it does for the game's own letters. The save holds an ordinary letter, so it keeps working without your mod. cmd.send_letter{ template = "welcome" } sends one of your own letters.json letters instead, with its greeting, sign-off, present and paper. Name the letter by its id or by its full name, "yourname.my-mod:welcome". cmd.give_item(item) | Puts an item into the first empty pocket. When the pockets are full, the item comes by letter instead. It also takes your mod's own new item by its full id, "yourname.my-mod:thing". A letter cannot carry a mod's own item, so full pockets refuse that one. cmd.show_line(text) | Shows a line in a message box with no one speaking. See where a line shows. cmd.ask{ text, choices } | Asks a question with 2 to 4 answers in the same window. The pick comes back as a question_answered event. cmd.take_item{ item, count? } | Asks the player to hand over items from their pockets. The game writes the question. See taking items or Bells. cmd.take_bells{ amount } | Asks the player to pay Bells from their wallet. The game writes the question. cmd.save() | Saves the game, where the player could save at Gyroid. See saving the game. cmd.set_weather(kind, intensity?) | Sets the town's weather for the rest of the game day: clear, rain or snow, light or heavy. See the weather. cmd.play_sound(name) | Plays one of the game's own sound effects for this player only, by its name in sounds.json. See sounds. cmd.set_shop_goods(shop, goods) | Sets a shop's goods for the rest of the game day, as one more block after your shops.json blocks for that shop. nil clears it. See the Shops guide. cmd.react(name) | Plays a reaction from the reactions bar on the player's own character: hooray, dance, hug, thanks, ouch, trip, spin, hide or pose. See reactions. cmd.set_shop_open(shop, open) | Opens (true) or shuts (false) a shop for the rest of the game day. nil clears it. cmd.set_hat(picture) | Puts a picture from your mod on the player's hat. nil takes it off. See the hat. cmd.set_shirt(picture) | Puts a picture from your mod on the player's shirt. nil takes it off. See the shirt. Each call returns the command's number, except the two shop commands, cmd.set_hat, cmd.set_shirt and cmd.react: they are set at once and return true. A call that is refused right away returns nil, a message and a code. The shop commands need "scope": "world", since a visitor sees the shop, and so does set_weather. To keep data of your own, use store. To save the player's game, see saving the game. main.lua: ```lua on("day_started", function(e) local id, why, code = cmd.send_letter{ text = "Good morning! Here is a little something for your day.", item = 0x2800, -- or "0x2800" from = "A friend", -- up to 8 characters } if not id then log("no letter today:", why, code) end end) on("command_finished", function(e) -- worked: e = { id, command, ok = true, via }; via is "mailbox" or "post_office" -- refused: e = { id, command, ok = false, code, message } if not e.ok then log(e.command, "#" .. e.id, "failed:", e.code, e.message) end end) ``` main.lua: ```lua on("villager_talked", function(e) if store.player.get("asked") then return nil end store.player.set("asked", true) cmd.ask{ text = "Tea or cake?", choices = { "Tea", "Cake" } } end) on("question_answered", function(e) -- e = { id, choice, text }: choice counts from 1; { id } alone when closed without a pick if e.choice == 2 then cmd.show_line("Cake it is!") end end) ``` ## Where a line or question shows cmd.show_line, cmd.ask, cmd.take_item and cmd.take_bells all use the message box the game shows when the player tries to pick something up with full pockets and reads "My pockets are full!". It is not a conversation with a villager: - No one is speaking. There is no name tag, and the box is tinted light blue. - It waits until the player is free: walking around, not talking to anyone, not in a menu. It never cuts into a conversation. - The player stops while the box is up and walks on once it closes. - One line or question shows at a time. The next one waits for the box to close. ## What comes back - command_finished when it worked is { id, command, ok = true, via }. via is "mailbox", "post_office", "pockets", "mail", "shown", "taken", "saved", "set", "unchanged" or "played". - command_finished when it was refused is { id, command, ok = false, code, message }. - question_answered is { id, choice, text }. choice counts from 1. When the window closed with no pick, the event is { id } alone. ## Taking items or Bells cmd.take_item and cmd.take_bells let a mod run a quest or a sale: "bring me three apples", "a peach costs 300 Bells". A mod never takes on its own word. The player agrees each time. - Your script queues the take. You give the item and the count, or the amount. You give no text. - When the player is free, the game asks its own question in that message box. It reads Give 3 x apple to the mod "Your Mod"? or, for the fruit contest of the Harvest Post example, Pay 100 Bells to the mod "Harvest Post"?. The item's name, the count and the amount come from the game. The mod's name is the name in its mod.json, shown between quotes. A script cannot change any of it. - The answers are No, keep it and Yes, give or Yes, pay. The cursor starts on No. - On yes, the items leave the pockets or the Bells leave the wallet. command_finished has ok = true and via = "taken". - On no, or when the window closes with no pick, nothing is taken. command_finished has code = "command-declined". main.lua: ```lua -- mod.json: "permissions": ["take_bells", "give_item", "show_line"] local PRICE = 300 on("villager_talked", function(e) if store.player.get("peach") then return nil end if (game.bells() or 0) < PRICE then return { place = "before", line = "A peach from my garden is " .. PRICE .. " Bells. Come back when you have them!" } end local id, why, code = cmd.take_bells{ amount = PRICE } if not id then log("no sale:", why, code) end return { place = "before", line = "A peach from my garden? Let me wrap one up." } end) on("command_finished", function(e) if e.command ~= "take_bells" then return end if e.ok then -- e.via is "taken": the player said yes and the Bells left the wallet store.player.set("peach", true) cmd.give_item(0x2803) elseif e.code == "command-declined" then cmd.show_line("Maybe another day.") else log("take_bells failed:", e.code, e.message) end end) ``` What can be taken: - List take_item or take_bells in "permissions". Players see "Can take items from your pockets, only when you say yes each time" before they install. - item is an item number, "0x2800" or your mod's own "author.mod:thing". count is 1 to 15 and is 1 when left out. - amount is a whole number of Bells, 1 to 99,999. - Only plain pocket slots count. A wrapped present and an item held for a villager's errand are never taken. An item number never matches a mod item that stands on that piece. - The goods of a villager's errand are refused by number too. So is anything give_item refuses: money bags, turnips, tickets, grab bags and fossils. - Bells come from the wallet only. The bank account and money bags are never touched. The wallet never goes below zero. - When the player does not hold enough, the take is refused with command-not-held and no question is shown. Check game.pockets() or game.bells() first. How often, and where: - Each game day, per mod and per town, the game shows 6 take_item questions and 6 take_bells questions. A take counts when its question is shown, whatever the answer. A mod cannot ask again and again. - On a visit to a friend and in The City, both are refused. The pockets there belong to a save the host's mods were never installed on. - A mod lent for a visit acts only on that visit, so a lent mod can never take anything. - Every take that happened is written to the Mod log, with the question the player agreed to. - A take sends no question_answered. Its one result is command_finished. ## Saving the game cmd.save() saves the player's town, as the Autosave setting does, from any event: a save each time the player steps outside, after a catch, or on a button of the mod's own. It takes no arguments. The save waits until the player is free, like every command, and the game then decides whether it may write. - The game saves only where the player could save at Gyroid: outdoors in their own town, walking or standing, with no menu, talk, cutscene or door. Anywhere else the save is refused with a code, and nothing is written. - It never changes the town being played. The game writes a settled copy of the town, so a save cannot lose or double an item, however often it runs. - command_finished has via = "saved" when the game wrote the town, and via = "unchanged" when nothing changed since the last save, so nothing was written. - Indoors it is refused with command-indoors. Inside a house the furniture still holds what is kept in its drawers, so the save would have that house with its storage empty. Save once the player is outside. - command-busy: the player is not in free control. command-dream: a dream town is never saved. command-not-ready: no save is loaded yet. command-save-failed: the write itself failed, for example when the browser's storage is full. - Two saves by mods, of all mods together, are at least 10 seconds apart, and one of your saves waits at a time. A save asked for sooner is refused at the call with command-too-soon. - Each game day, per mod and per town, the game writes 32 saves. Only a save that wrote the town counts. Every save also uploads the town to the cloud, so do not save on a timer of your own: the Autosave setting is there for that. - On a visit to a friend and in The City it is refused. A visitor's game does not hold the town it stands in. - It saves what Gyroid's save saves, except a villager's mood and clothes, which reach the save at the next change of scene. A save in a script never replaces Gyroid: the player still saves and quits there. - List save in "permissions". It arrived in API 1.1, so a playac-mod older than 1.1.0 does not know it. Players see "Can save your game" before they install. main.lua: ```lua -- mod.json: "permissions": ["save", "show_line"], -- "scripts": { "main": "main.lua", "events": ["scene_entered", "command_finished"] } on("scene_entered", function(e) if e.name ~= "town" then return end -- the save waits until the player is free outdoors, then the game writes it local id, why, code = cmd.save() if not id then log("no save:", code) end end) on("command_finished", function(e) if e.command ~= "save" then return end if e.ok and e.via == "saved" then cmd.show_line("Saved!") elseif not e.ok then log("save refused:", e.code, e.message) end end) ``` ## Sounds cmd.play_sound(name) plays one of the game's own sound effects: the jingle of getting an item, the menu cursor's tick, a page turning in the message window. A mod names a sound from the sounds list, never a number. main.lua: ```lua -- mod.json: "permissions": ["play_sound"] on("bug_caught", function(e) local id, why, code = cmd.play_sound("item_get") -- a name from sounds.json if not id then log("no sound:", why, code) end end) ``` - List play_sound in "permissions" (new in API 1.1). Players see "Can play the game's sound effects, heard only by you" before they install. - Every sound in the list is one the game plays once and stops on its own. None loops, and none is one a scene starts and stops itself. - Only this player hears it. On a visit the friend does not hear it, and nothing reaches the town or the save. In The City it is refused. - A sound changes nothing, so it does not wait for the player to be free. It plays at the end of the next frame's update, in a talk or a menu too, and never waits behind a line. - At most 2 sounds in one event, inside the 4 commands. At most 10 a minute for each mod, counting the ones still waiting: more is refused with command-sound-cap. There is no daily limit. - While the player plays an NES game the sound belongs to it, and a sound is refused with command-no-sound. - command_finished says via = "played". ## The weather cmd.set_weather(kind, intensity) sets the town's weather for the rest of the game day, for a rainy festival, a snow day or a sunny contest. kind is "clear", "rain" or "snow", and for rain or snow intensity is "light" (when left out) or "heavy". Heavy rain is a storm, heavy snow a blizzard. The Button Tricks example steps through them on the D-pad. - The game changes the weather the way it changes it on its own: the last drops or flakes fall, then the new weather fades in, with its light and its sound. Villagers open umbrellas, and fish and bugs follow the weather, as on any rainy or snowy day. Heavy rain brings lightning in June, July and August, as the game's own storms do. - It lasts until the day changes. Then the game rolls its own weather again. A day after rain or snow can bring a rainbow and a gyroid in the ground, as after a real rainy day. A reload the same day keeps your weather. - Only weather the game itself could roll on that date is allowed. Clear is always allowed. Rain falls from February 25 to November 15 and snow from November 1 to February 24, light or heavy, and neither on the days the game keeps clear: January 1 to 7, April 1 to 8, April 20, October 31 and December 31. - On an event day the event's weather holds, and the player's first day of work for Nook never rains. A weather the game would not have today is refused with command-weather, at the call when it can tell then. - command_finished has via = "set" when the weather changed, and via = "unchanged" when the town already had it, as game.weather() reads it. Cherry blossom petals and falling leaves count as clear, so on those days "clear" is unchanged and the petals or leaves stay: putting back the weather you read changes nothing. While a change of weather is still under way, the command waits for it to end. - Each game day, per mod and per town, the weather changes 4 times. Only a change counts. - It is refused on a visit and in The City. The host's game decides the weather, and a visitor sees the host's weather through the game itself, with or without your mod. A host's change reaches a visitor already in the town. - List set_weather in "permissions", with "scope": "world" (new in API 1.1). Players see "Can change your town's weather for the day" before they install. A mod that only sets the weather never has to match on a visit. main.lua: ```lua -- mod.json: "scope": "world", "permissions": ["set_weather"], -- "scripts": { "main": "main.lua", "events": ["hour_changed", "command_finished"] } on("hour_changed", function(e) if e.hour == 8 then local id, why, code = cmd.set_weather("rain") if not id then log("no rain today:", code) end -- command-weather in the snowy months elseif e.hour == 12 then cmd.set_weather("clear") end end) on("command_finished", function(e) if e.command == "set_weather" and not e.ok then log("weather refused:", e.code, e.message) end end) ``` ## The hat cmd.set_hat("hats/stripes.png") puts a picture from your mod on the pointy hat of the player playing now, in place of the design or the shirt the hat wears. cmd.set_hat(nil) takes it off. It is set at once and shows from the next frame. New hat shapes and hair need 3D models, which mods cannot add yet. The Button Tricks example puts on a hat and a shirt of its own. - List set_hat in "permissions". It arrived in API 1.1. It works in a Just you mod. - The picture is a PNG inside your mod, by its path from the top of the mod, outside your textures folder. It is exactly 32 x 32 pixels with at most 16 colours and no see-through pixels, like an Able Sisters design. Anything else is refused with command-picture. - A hat from a mod beats a design on the hat. When two mods set one, the mod lower in the Mods tab list wins. - The hat belongs to the player who wears it, wherever they go: a hat set at home stays on when they visit a friend or go to The City. Only that player's own screen draws it: friends on a visit and players in The City see the hat the game would draw. - The game saves nothing about it. The hat is gone when the game restarts, and stays on when you reload the script in developer mode. Keep the pick in store.player and set it again from scene_entered, which also runs for the first scene of a session. Away from home store.player starts empty, so set the hat only when it holds a pick, as the sample does. main.lua: ```lua -- mod.json: "permissions": ["set_hat"], "scripts": { "events": ["scene_entered"] } -- hats/stripes.png: 32 x 32, at most 16 colours, no see-through pixels on("scene_entered", function(e) local picture = store.player.get("hat") -- nil: the game's own hat if picture then local ok, why, code = cmd.set_hat(picture) if not ok then log("no hat:", why, code) end end end) -- wherever the player picks one (a question, a villager, a day): store.player.set("hat", "hats/stripes.png") cmd.set_hat("hats/stripes.png") ``` ## The shirt cmd.set_shirt("shirts/stripes.png") puts a picture from your mod on the shirt of the player playing now, in place of the clothes they wear. cmd.set_shirt(nil) takes it off. It follows every rule of the hat: the same permission rules (list set_shirt), the same picture, the same command-picture refusals, the same load order, it follows the player onto a visit and into The City, and nothing is saved. - The picture wraps the body and the sleeves the way an Able Sisters design does, so a design drawn for a shirt looks the same here. - It beats the clothes the player wears. Putting on other clothes changes what is underneath, and your picture stays on top until your mod takes it off. The save keeps the real clothes. - The hat matches the shirt, as in the game: with no design and no mod hat on it, the hat wears your shirt picture too. Set a hat as well to give it a picture of its own. - Only the player's own screen draws it: friends on a visit and players in The City see the clothes the player wears. main.lua: ```lua -- mod.json: "permissions": ["set_shirt"], "scripts": { "events": ["scene_entered"] } -- shirts/stripes.png: 32 x 32, at most 16 colours, no see-through pixels on("scene_entered", function(e) local picture = store.player.get("shirt") -- nil: the clothes the player wears if picture then local ok, why, code = cmd.set_shirt(picture) if not ok then log("no shirt:", why, code) end end end) ``` ## Reactions cmd.react(name) plays one of the reactions bar's nine on the player's own character, the same way the bar does. Friends on a visit and players in The City see it as they see one from the bar. The game is asked at the call, and the reaction plays from the next frame for at most a second and a half. Any move after the first moment walks out of it. - It needs "react" in "permissions" (new in API 1.1), and works in a Just you mod. - Only while the player is free. During a menu, a talk, a message, a door, a cutscene or a scene change it returns nil with command-busy. So does an action the player just started, so a player_acted handler gets command-busy: react later, from a timer. - One reaction at a time. Once one is taken the player is in it, and a second call in the same moment is command-busy. - Only from standing, walking or running. Sitting, lying in bed, a tool swing or holding furniture: command-cannot-react. Read game.player().state first. - At most 10 a minute for each mod (command-minute-cap). A refused reaction does not count. - It works on a visit and in The City: it moves only your own character and changes nothing saved. - When it plays, player_acted fires with action = "reacted" and its reaction. ## Refusal codes A refusal carries a code that never changes. It is the third return value of cmd.* and the code field of command_finished. Test the code, not the message. The table says whether trying again can work. Code | Try again | When command-shop | never | A shop command the shop cannot take: the shop is not in the shop table, it has no goods or no open, or a mod later in the load order changes that shop. command-permission | never | The command is not in mod.json permissions. command-args | never | Wrong arguments, such as their shape, a length, the paper or the choices. command-item | never | An item the command cannot hand out, or an unknown item or letter id of the mod's own. Also sent in command_finished when the mod's item or letter was gone by the time the game applied the command. command-event-cap | in the next event | More than commands.per_event commands in one event. command-queue-full | later | The mod's queue, or the game's, is full. command-day-cap | tomorrow | The per-day limit for this command in this town is used up. command-city | later | Commands are off in The City. command-visiting | later | On a visit, only the town owner's game changes the town. command-lent-home | never | A lent mod acting outside the host's town. It arrives in command_finished, never as the return of a cmd call. command-no-room | later | No room now. The mailbox and the post office are full, or the pockets are full for a mod item. The command still counts against the day's cap, so do not try again in a loop. command-not-shown | never | The line or question cannot be drawn in the window, because the text has too many pages. The command still counts against the day's cap. command-not-held | later | A take the player cannot meet. The pockets do not hold that many of the item in plain slots, or the wallet holds fewer Bells. command-declined | later | The player said no to a take's question, or closed it with no pick. Nothing was taken. command-client-setting | never | The event read a client setting, and a client setting cannot decide what the town gets or gives up. Make the setting world, or do not read it in an event that sends a letter, gives an item, or takes an item or Bells. command-not-ready | later | A save before the player's save has loaded, or while the page is replacing or restoring the save. command-indoors | later | A save anywhere but the town outdoors: a house, a shop, a museum, the train. Inside a house the furniture still holds the items kept in it, so the game would save the house with its storage empty. command-picture | never | cmd.set_hat's or cmd.set_shirt's picture is not in the mod, or is not a 32 x 32 PNG with opaque pixels and at most 16 colours. command-busy | later | The player is not free now: a menu, a talk, a message window, a door, a cutscene, a tool swing or a scene change has them. For cmd.save, also right after the game itself settled this scene for a save that did not finish, until the next change of scene. For cmd.react, also an action they just started (as in a player_acted handler) or a reaction already playing. Try again from a later moment. command-dream | later | A save in a dream town. A dream is never written to the player's save. command-too-soon | later | A save within commands.save_spacing_seconds of the last save by any mod, or a second save while this mod's last one is still waiting. command-save-failed | later | The game could not write the save file. The town in play is unchanged. command-weather | later | A weather the game would not have today: snow outside the months it snows, rain outside the months it rains, any weather but the event's on an event day, or rain on the player's first day of work for Nook. The date decides, so the next day may allow it. command-sound-cap | later | A sound when this mod already played commands.sounds_per_minute sounds in the last minute, counting the ones still waiting. Wait and play it later. command-no-sound | later | A sound while an NES game is being played: the game's sound belongs to the NES game until it ends. command-cannot-react | later | cmd.react: the game did not take the reaction. It plays only while the player stands, walks or runs, so not while sitting, lying, swinging a tool or holding furniture, and something more important (a talk, a door, a bee) outranks it. command-minute-cap | later | cmd.react: the mod already played commands.reacts_per_minute reactions this minute of the game clock. Try again next minute. Mark a reward as given only in command_finished, when e.ok is true. A command can be refused after the call returns. A closed tab loses a command that is still waiting. main.lua: ```lua local waiting = false -- a letter is queued and has not finished local rest_day = nil -- the day whose cap ran out local function send() if waiting or rest_day == game.day_number() then return end if store.player.get("reward") then return end -- given, or never to be local id, why, code = cmd.send_letter{ template = "reward" } if id then waiting = true elseif code == "command-day-cap" then rest_day = game.day_number() end end on("day_started", send) on("scene_entered", send) -- the codes whose "try again" is later or in the next event local AGAIN = { ["command-no-room"] = true, ["command-queue-full"] = true, ["command-city"] = true, ["command-visiting"] = true, ["command-event-cap"] = true, } on("command_finished", function(e) if e.command ~= "send_letter" then return end waiting = false if e.ok then store.player.set("reward", "given") elseif e.code == "command-day-cap" then rest_day = game.day_number() -- tomorrow elseif AGAIN[e.code] then -- the next scene_entered sends again else store.player.set("reward", "refused") -- never: do not ask again log("reward not sent:", e.code, e.message) end end) ``` ## The rules What a command may carry: - Items follow the shop's rules. Money, turnips, tickets, grab bags, fossils and reserved numbers are refused. - A letter's text is 1 to 192 characters and must fit its 6 lines. - from is up to 8 characters on one line. paper is 0 to 63. - A line is up to 400 bytes. - A question is up to 120 characters. Each answer is up to 16 characters. How many: - At most 4 commands in one event. - Each game day, per mod and per town: 3 letters, 5 items, 20 lines and 10 questions. The count is kept across a reload. - Also each game day: 6 questions for items and 6 for Bells. See taking items or Bells. - And 32 saves, at least 10 seconds apart. See saving the game. - And 4 changes of weather. See the weather. - The day's caps cover all of a town's residents together (up to 4). They are a safety limit, not a game rule. - A command counts when the game applies it. Commands still waiting count toward the cap. A command lost with a closed tab before the game applied it never counts. - A command the game applied counts even when it failed. A letter refused with command-no-room for a full mailbox uses one of the day's letters. So does a line refused with command-not-shown. Try again from a later event, never in a loop. - At most 8 of your commands wait at once. - The window shows one line or question at a time. The next waits until the window closes. Where the player is: - In The City, every command but cmd.set_hat, cmd.set_shirt and cmd.react is refused. - On a visit to a friend, letters, items, takes, saves and the weather are refused, because only a town's owner changes a town or a save. Lines, questions, sounds and reactions still run. - A command refused for where the player is never counts against the day's caps. - Called there, the command returns nil, the message and the code at once. - Queued at home and applied after the player left, it comes back as a refused command_finished. Where a refusal shows: - A command refused when you call it is written to the Mod log with your mod, the event and the command. - A command refused later, when the game applies it, arrives as command_finished with ok = false, the code and the message. The refusal is also written to the Mod log. - Handle command_finished to act on a refusal. The Mod log is for reading, and a script cannot read it. - Every message is on the errors page. The script of example.harvest-post is a whole working example. It sends each resident a letter with a fruit once a game day, and tries again later when the game refuses. Copy it from the cookbook. --- ## Page: https://playaconline.com/modding/guides/dependencies/ ## Dependencies, conflicts and mod-to-mod calls A mod can name the mods it needs, the mods it can use when they are there, and the mods it cannot run with. It can also call functions another mod offers. ## depends and conflicts mod.json: ```json "depends": { "yourname.tea-lib": ">=1.0.0 <2.0.0" }, "conflicts": { "someone.other-shop": "*" } ``` - Each entry is a mod id and a version range. Each key holds at most 16 entries. - A range is * for any version, or up to 4 comparisons split by one space. A comparison is >=, <=, >, < or = and a version. - 1.2.3 alone means exactly that version. ^ and ~ are not ranges here. - A mod cannot name itself. A mod id goes in only one of depends, optional_depends and conflicts. ## What the game does with them - A mod loads after the mods it depends on. Otherwise the player's order in the Mods tab stands. A mod moves only as far as its dependencies need. - A mod is not loaded when a mod it depends on is missing, switched off, the wrong version or failed to load. Its row in the Mods tab says why and names the mod it needs. - A mod stays off when it lists a conflict with a mod that is on in a matching version. Its row gives that reason. - Mods that need each other in a circle cannot load. - The friend visit match uses this same order. ## Optional dependencies optional_depends names mods yours can use but does not need. It has the same shape and the same ranges as depends, and holds at most 16 entries. Your mod always loads. mod.json (part): ```json "optional_depends": { "yourname.weather": ">=1.0.0 <2.0.0" } ``` - An optional dependency is present when it is installed, switched on, loading and inside the range. - A present one loads before your mod, exactly as a needed one does. - It is absent in every other case: not installed, switched off, not loading, or a version outside the range. Nothing waits for an absent one, and your mod loads in the player's order. - The Mods tab lists them on your mod's row. One the player has on reads "Works with , which you have on." One that is off or missing reads "Also works with ". It is plain text, never a warning. ## Asking whether it is there remote.version(mod) answers for a mod you name in depends or optional_depends. It returns the version, such as "1.2.0", when the mod is present. When it is not, it returns nil, a message and a code. main.lua: ```lua on("villager_talked", function(e) -- the version when it is there, or nil, a message and a code local version, why, code = remote.version("yourname.weather") if not version then return { place = "before", line = "Lovely day, I think." } -- code is "dependency-absent" end local sky = remote.call("yourname.weather", "today") return { place = "before", line = "They say it will be " .. sky .. " today." } end) ``` Code | When dependency-absent | The mod is not installed, is switched off, did not load, or has no running script. dependency-version | The mod loaded, but its version is outside the range this mod names. dependency-undeclared | The mod is not in this mod's depends or optional_depends. ## Calling it when it is absent remote.call to an absent optional dependency is not an error. It calls nothing and returns nil, a message and one of the codes above. Your script keeps running. main.lua: ```lua local sky, why, code = remote.call("yourname.weather", "today") if sky == nil and code then -- the weather mod is not there: nothing was called, nothing was raised sky = "fine" end ``` - A function that itself returns nil gives one nil and no code. The code tells the two apart. - A call to a mod you did not name keeps its old meaning. It raises an error when that mod has no running script. - A present dependency that does not offer the function still raises an error. Check with remote.has when you are not sure of the name. ## Two mods that use each other - A circle through an optional dependency never stops a mod from loading. - The game cannot load both first. The mod that is earlier in the player's order loads first, and the other loads after it. - Both are still present. remote.version and remote.call work in events for both. - Only the "loads first" promise is dropped, for the mod that went first. Its top level runs before the other mod's script exists. Ask and call in an event, not at the top of the script. - A circle made only of needed dependencies is still refused. ## Calls between mods A mod offers functions with remote.add(name, fn) while its script loads. Another mod calls them with remote.call(mod, name, ...). Check first with remote.has(mod, name). tea-lib/main.lua: ```lua -- yourname.tea-lib: offer a function while the script loads remote.add("brew", function(kind, cups) return { kind = kind, cups = cups, hot = true } end) ``` main.lua: ```lua -- a mod that depends on yourname.tea-lib on("villager_talked", function(e) if not remote.has("yourname.tea-lib", "brew") then return nil end local tea = remote.call("yourname.tea-lib", "brew", "green", 2) return { place = "before", line = "Two cups of " .. tea.kind .. " tea!" } end) ``` - Arguments and results are copied. They can be nil, true or false, numbers, text and tables of those. The limits are 64 KB, 16 levels deep and 8 results. - Functions cannot be passed. Changing a copy never changes the other mod's table. - The function you call runs on your time budget. If it runs too long, your script is stopped and the other mod keeps running. - Its commands count toward your event's cap. The cap covers your commands and those of every mod you call, together. - Its rng() draws from that mod's own numbers, not yours. - A call runs at once. It is not one of the other mod's events, so it does not wait behind events that mod still has queued. - An error inside the other mod's function comes back as your error. Catch it with pcall. The other mod keeps running. - A call back into a mod that is already running is refused, so calls cannot loop. That covers your own mod and any mod further up the chain of calls. - A name is 1 to 32 characters from a-z 0-9 _. A mod offers at most 32 names. Calls work between any two running mods. List the mods you call in depends anyway. Then your mod loads after them, and players see what is missing instead of a script error. The game checks depends again when it starts, and does not load a mod whose dependency did not load before it. ## A library mod A mod that only offers functions to other mods still needs a scripts section, and scripts.events must list at least one event. List one and register no handler for it. An event with no handler costs nothing and never runs your script. The script's top level, where remote.add is called, runs once when the game starts. mod.json (part): ```json "scripts": { "main": "main.lua", "events": ["day_started"] } ``` List what your library offers in exports. Each entry is a function's name and one line saying what it does. It holds at most 32 entries, with descriptions up to 120 characters. The key is optional and needs scripts. mod.json (part): ```json "exports": { "brew": "Makes tea: brew(kind, cups) returns { kind, cups, hot }." } ``` - With exports, remote.add can offer only the names it lists. The Mod log says when a listed name was never offered. - Each name comes with a one-line description, so the author of a mod that depends on yours knows what to call. ## Dependencies and friend visits - A visit compares only World mods. A Just you mod never blocks a visit, even when another mod depends on it. - A World mod that depends on a Just you mod loads only where that Just you mod is installed and on. A friend who has your World mod without it cannot load your World mod. The two towns then differ, and the visit is refused, naming your World mod. - Visiting with the host's mods does not help, because only World mods are lent. - A World mod should depend only on World mods, or on nothing. When a World mod needs a library, make the library "world" too. - An optional dependency is a mod like any other for a visit. When it is a World mod that counts, it is part of what the visit compares. A friend who has your mod without it has a different set, and the visit says which mod differs. - An optional dependency that is a Just you mod never blocks a visit. Your World mod loads on both sides, with it or without it. - A visitor who borrows the host's mods gets every World mod of the host that counts, optional dependencies included. --- ## Page: https://playaconline.com/modding/guides/lines/ ## Lines and messages Villagers can say lines you wrote, anywhere in their talk: before their hello, as the hello, as the topic, after it, or as the whole conversation. A talk file, with no code, does it with pools kept to a villager, a season, a time of day, the weather or a calendar day. A Lua script uses the same places, decides in code, and can ask the player a question. The writer path has a kit for the first, and the scripter path has one for the second. ## Talk file or script | Talk file (talk.json) | Script (main.lua) Code | None | Lua Who says it | Everyone, a personality or one villager | Whoever your script picks Where in the talk | Any place: every pool names its "place" | Any place: every line names its place When | Kept to a season, time, weather or calendar day if you like | When your script says, such as only with an item in the pockets A question | No | Yes, in a conversation (ask) How often | chance in 100 talks the pool fits. Nothing is saved. | Your script keeps track, with store if it must last Kit | | ## Places in a talk A villager's talk is their hello, then a menu of three answers: one about an errand, one to chat, such as "I'm bored!", and "Never mind". Choose to chat, and the villager picks a topic, fresh each time: small talk, a trade, a letter they got, a memory, a hint, or news of an event. Your words can go in five places: Place | Where your line goes | What of the game's still plays before | In front of the hello | All of it: the hello, the menu, the topic hello | Instead of the hello. End it so the menu reads well after it. | The menu and the topic. Only an everyday hello is replaced: one with news, such as a bee sting or a finished bug collection, is kept and your line is not said. topic | Instead of the topic the game picked, when you choose to chat and it is one of the line's topics | The hello and the menu. The talk ends after your line, as small talk does. after | After the topic, as the talk's last message, when you choose to chat | Everything, then your line conversation | The whole talk | Nothing: no hello, no menu, no topic. Your pages, then the talk ends. A script may ask a question. topics names the topics a topic line may stand in for: small_talk (the weather, the time of day, the month, plain chat), trade, letter, memory, hint and news. Leave it out for small talk, or write "any" for all six. A trade your line replaces does not happen: nothing changes hands. A line is one page, which the game wraps over as many windows as it needs, or a list of 1 to 8 pages. Each page in a list starts on a clean window, after the player presses A. ## Talk pools A talk file holds pools of lines. Name it in mod.json under content.talk. This is the lines kit's: mod.json (part): ```json "content": { "talk": "talk.json" } ``` talk.json: ```json { "pools": [ { "place": "topic", "lines": [ "Did you hear? The river was extra sparkly this morning.", "I've been practising my whistling. Want to hear? Maybe later.", "If you find a shiny rock, tell me first, okay?" ] }, { "place": "topic", "weather": "rain", "lines": [ "Rain, rain, rain! The puddles are perfect for stomping." ] }, { "place": "topic", "time": "evening", "lines": [ "The sky goes all orange this time of day. I love it." ] }, { "place": "topic", "personality": "peppy", "lines": [ "Ooh, it's you! Today is going to be amazing, I can tell!", "I did ten twirls in a row this morning. Ten!" ] }, { "place": "topic", "personality": "lazy", "lines": [ "I had a snack, then a nap, then another snack. Busy day." ] }, { "place": "topic", "personality": "cranky", "lines": [ "Hmph. You again. Well, I suppose that's fine.", "Back in my day, the trees were taller." ] }, { "place": "topic", "personality": "cranky", "season": "winter", "lines": [ "Cold enough to freeze a fish. Don't stand there, it's cold." ] }, { "place": "topic", "villager": "Bob", "chance": 80, "lines": [ "Bob here! I've been thinking about lunch all day." ] } ] } ``` ## A pool's place Every pool names its place; there is no default. The kit's pools are topic lines for small talk. This file has one pool for each place: talk.json: ```json { "pools": [ { "place": "before", "chance": 20, "lines": ["Psst! Over here!"] }, { "place": "hello", "weather": "rain", "lines": [["Oh, hi! Isn't the rain\nlovely?", "The flowers think so."]] }, { "place": "topic", "topics": ["trade", "small_talk"], "lines": ["No deals today. Let's\njust talk."] }, { "place": "after", "time": "evening", "lines": ["Getting late. Get home\nsafe!"] }, { "place": "conversation", "villager": "Bob", "day": "bob-day", "lines": [["It's Bob Day! The whole\ntown knows it.", "Well, I know it. Bye!"]] } ] } ``` - Every talk is asked again, so the same villager can say several of your lines in one day. - A villager never says the same line twice running when the pools hold another. - A conversation pool takes the whole talk when it fits and its chance rolls yes. Keep it rare, or to one villager or one day. ## The keys of a pool Each pool has lines. Every other key is optional and keeps the pool to a villager or a moment: talk.json: ```json { "pools": [ { "place": "topic", "personality": "cranky", "lines": ["Hmph. Another day of\nyou walking around.", "What now? I was just\ngetting comfortable."] }, { "place": "topic", "weather": "rain", "lines": ["Rain again. The flowers\nare loving it, at least."] }, { "place": "topic", "season": "fall", "time": "evening", "chance": 30, "lines": ["The evenings come so\nearly now. I like it."] } ] } ``` - lines is 1 to 32 lines. A line is a page of 1 to 160 characters, with at most 3 line breaks, written \n, or a list of 1 to 8 such pages. The game wraps a page for you, see how a line is shown. - place is before, hello, topic, after or conversation, and every pool needs one. topics goes only with topic. - personality is one of normal, peppy, lazy, jock, cranky and snooty. - villager is one villager's name, in any case. A pool has a personality or a villager or neither, never both. With neither, it is for everyone. - season is spring (March to May), summer (June to August), fall (September to November) or winter (December to February). - time is one of the game's own four: morning (5 to 12), day (12 to 17), evening (17 to midnight) and night (midnight to 5). - weather is clear, rain or snow. Cherry blossom and falling leaves count as clear. - day is the id of a day in your mod's calendar file. The pool fits only on that day. - chance is 1 to 100: in how many talks in 100 the pool's line is said, when the pool fits. Leave it out and the pool says it every time it fits. For a topic line, the game picks small talk on roughly one chat in four or five (more often with a happy villager), so a lower chance leaves room for the game's own. - A file holds 1 to 32 pools. ## How a line is picked - Each place is picked on its own, from the pools of that place. A topic line also needs the game's topic to be one of its topics. - The game takes the most specific pools that fit: those kept to today's calendar day, then the villager's own by name, else their personality's, else everyone's. Only that level counts. - A pool fits when its season, time, weather and day, the ones it names, are the ones now. A pool that names none of them always fits. - Each pool that fits rolls its chance. - The lines of the pools that pass, from every mod, are put together, and one is picked. - When every pool at that level rolls no, that part of the talk stays the game's. The less specific pools are not asked instead. In the kit, a peppy villager says a peppy line, and a jock says a line for everyone, because no pool names jocks. Bob has his own pool with a chance of 80, so in most of his small talks he says his line, and in the rest he makes the game's own small talk. - Between mods, pools are not ranked by load order. Every mod's lines at the same level go in together. - Nothing is saved. There is no record of who said what, so a restart changes nothing. - Pools work in either scope, and in The City too. ## Calendar days A pool with a day speaks only on that calendar day, in its place, and on the day it comes ahead of every pool kept to no day, villager and personality pools too. Give it a chance to leave room for the other pools and the game's own talk. A calendar day needs no notice or letter to be named by a pool. ## Where a line never appears - A topic or after line, in a talk where you pick the errand answer or "Never mind". Only the chat answer leads to a topic. - A first meeting. - An errand, delivery or contest going with the player. - A villager moving out. - The first-job errands, and a new player's first ten chats: those topics are tips from the villagers, one a chat, until all ten are given. - A pitfall or a bee chase. - An islander. - The "should I move?" topic of a villager who is thinking of leaving. - The menu. Its three answers are the game's. ## When to use a script To say something only when something in the game is true, such as an item in the pockets, or to ask the player a question and answer what they pick, use a script. See Saying a line with villager_talked below. ## The messages file A script's lines go in a messages file, a JSON file of keys and lines. A script reads one with message("key"). Name the file in mod.json under content.messages. Call it messages.json and keep it at the top of the mod, next to mod.json. This is the script kit's: mod.json (part): ```json "content": { "messages": "messages.json" } ``` messages.json: ```json { "apple": "Is that an apple in your pockets? It smells wonderful!", "first_fish": "My first fish of the day!", "fair": "It's the Harvest Fair today. I should take some fruit to town." } ``` - A key is 1 to 48 characters. It uses only lower case letters, digits, _, . and -. - A mod holds up to 256 keys. - Each line is 1 to 400 bytes. An English letter is one byte. Accented letters and other alphabets take more. - Inside a line, \n starts a new line and \" is a quote mark. - A key's full name is your-id:key. Two mods can both have an apple key without clashing. Reference: messages file, with every field, limit and error code. ## How a line is shown - The game wraps a line by its width, not by counting characters. One line holds 180 pixels of the game's font, which is about 24 letters. Narrow letters like i and l fit more. Wide letters like W and m fit fewer. - A page holds 4 lines. A long text runs over several pages, and the player presses A to read on. - A text that only just spills over leaves a last page with one word on it. Read your lines in the game. - A character the game's font does not have shows as ?. Plain English letters, digits and common punctuation are safe. Test anything else. - Each page in a list of pages starts a clean window. A page of a hello or a question is best kept short. - Lines are for ordinary talks only. A special talk never reaches mods. Examples are a first meeting, a villager moving out, an errand in progress and a complaint. The villager's next ordinary talk reaches mods as usual. ## The characters the game draws The game's font draws every printable ASCII character in a line except $ * ^ | \, which each show as ?. [ ] { } show as parentheses. It also draws these: ¿ Ä À Á Â Ã Å Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ù Ú Û Ü ß Þ à á â ã ä å ç è é ê ë ì í î ï · ð ñ ò ó ô õ ö ù ú û ü ý ÿ þ Ý § ª º µ ³ ² ¹ Æ æ « » × ÷. Curly quotes, dashes and the ellipsis become their plain spelling. Anything else shows as ?, such as an emoji or a Polish or Greek letter. Letters and board notices take plain ASCII only. ## Saying a line with villager_talked A messages file does nothing on its own. A script picks a line and returns it from a villager_talked handler. The event's e.villager table has the villager's name and a number, id, that stays the same for that villager. main.lua: ```lua on("villager_talked", function(e) return { place = "before", line = "Oh, it's you! " .. e.villager.name .. " is always glad to see you." } end) ``` Every line names its place: a plain string returned alone is refused, and the Mod log says so. To use a line from your messages file, call message("key"). It returns the line, or nil if there is no such key. ## Any place from a script Return a talk table, { place, line, topics, ask }, or a list of them, one a place. place is required. line is a string or a list of 1 to 8 pages. main.lua: ```lua on("villager_talked", function(e) return { { place = "hello", line = { "Hi, " .. e.villager.name .. " here!", "Nice day, right?" } }, { place = "topic", topics = "any", line = "Let's skip the news." }, { place = "after", line = "See you around!" }, } end) ``` - The topic and after lines are said only if the player chooses to chat. A topic line also needs the game's topic to be one of its topics. - A table that is not right, such as an unknown place, is written to the Mod log and nothing of it is said. ## A conversation that asks A conversation may end in ask = { text, choices }, a question with 2 to 4 answers of up to 16 characters. The player's pick goes to your villager_answered handler, with e.villager, e.choice (counting from 1) and e.text. Return what the villager says next: a line, or { line, ask } to ask again. Return nil and the talk ends. List villager_answered in scripts.events. main.lua: ```lua on("villager_talked", function(e) return { place = "conversation", line = "I baked today.", ask = { text = "Tea or cake?", choices = { "Tea", "Cake" } }, } end) on("villager_answered", function(e) if e.text == "Cake" then return { line = "Cake it is!", ask = { text = "A big slice?", choices = { "Yes", "No" } } } end if e.text == "Yes" then return "Enjoy!" end return "Tea, then. Lovely." end) ``` ## A line that depends on something This is the talk part of the script kit. A villager notices an apple in your pockets, once a day each. APPLE is 0x2800, the apple's item number. main.lua (part): ```lua local noticed = {} -- villagers who noticed an apple, by id local noticed_on = nil -- the day that list is for local function holding(item) for _, p in ipairs(game.pockets()) do if p.item == item then return true end end return false end -- "notice" is a setting in mod.json, which the player turns on or off on -- the Mods tab. settings.get reads it. This is a Just you mod, so a setting's -- "scope" changes nothing a visit sees, and it is left out. -- The handler returns a talk table, and every line names its place: here -- "before", said before the villager's hello. The others are "hello" (instead -- of the hello), "topic" and "after" (when you chat), and "conversation" for -- the whole talk (with an ask, the player's pick comes to villager_answered). -- A plain string with no place is refused. A line can be a list of pages: -- line = { "Page one.", "Page two." }. on("villager_talked", function(e) if not settings.get("notice") then return nil end if noticed_on ~= game.day_number() then noticed, noticed_on = {}, game.day_number() end if noticed[e.villager.id] or not holding(APPLE) then return nil end noticed[e.villager.id] = true return { place = "before", line = message("apple") } end) ``` - game.pockets() lists what you hold, one table per item with its slot and item. - With no apple, the handler returns nil. The talk then goes to the next mod's script. - game.day_number() goes up by one each game day, so the list of who noticed starts again each day. The list is kept in memory, so it is also empty after a restart. - The same shape works for the time with game.time(), the town and season with game.town(), and anything your script saved with store. ## Lines from another mod A full key with a colon reads another mod's line. If that mod is not installed or is switched off, you get nil. Always check: main.lua: ```lua on("villager_talked", function(e) local contest = message("example.harvest-post:contest") -- nil if Harvest Post is not installed if contest then return { place = "after", line = contest } end return nil end) ``` ## When two mods want the same talk - Each place takes one line a talk. - Scripts come first. Every script's villager_talked runs, in the order of the Mods tab list, from the top. The first line returned for a place takes it. A later script's line for that place is written to its Mod log and not said. - A conversation needs every place free, and then takes the whole talk: the scripts below it are not asked. - Then the pools fill each place no script took. Pools are not ranked by order: the lines of every mod are put together and one is picked. - A conversation pool is used only when no script took any place. Return nil when you have nothing to say, so other mods get their turn. A shop's greeting and stock line live in shops.json, in a block's lines, not in the messages file. See the Shops guide. --- ## Page: https://playaconline.com/modding/guides/mod-items/ ## New items in mods A mod can add furniture of its own for the house. Each item has its own id, name and price. It uses the model of a real piece of furniture, called its base. Players buy it at your flower shop or at Nook's. Your script can also give it with cmd.give_item. ## The items file Name the file in mod.json: mod.json: ```json { "schema": 1, "api": 1, "id": "example.after-hours", "name": "After Hours", "version": "1.0.0", "authors": [ "Play AC Online" ], "description": "From 1 AM to 3 AM the town shop opens again, and all it sells is gyroids. A different few stand on the floor each night, and among them, now and then, a Ghost Lantern of the mod's own, its windows glowing green. Every other spot is empty. The rest of the day the shop is its usual self. Remove the mod and a Ghost Lantern you bought stays in your house as the plain tall lantern it is built on.", "scope": "world", "content": { "items": "items.json", "shops": "shops.json" }, "assets_original": true } ``` items.json: ```json { "items": [ { "id": "ghost-lantern", "name": "Ghost Lantern", "base": "0x122C", "price": 2600, "textures": "items/ghost-lantern/" } ] } ``` - id is 1 to 32 characters from a-z, 0-9 and -. The item's full id is your mod id, a colon, then this id, as in example.after-hours:ghost-lantern. Never change it once players have the item. Use renames instead. - name is 1 to 16 characters, the size of the game's item name box. It may use letters, digits, spaces and ' . , ! & -. It starts with a letter or digit. - base is the furniture whose model the item uses. Write "0x" and 4 hex digits for the piece facing south. That is 0x1000 to 0x1FFC or 0x3000 to 0x33C4, in multiples of 4. - Some furniture cannot be a base. See Which furniture can be a base. - price is optional, 1 to 99999 Bells. A shop asks this price when its stock sets none. - textures is optional: a folder of the item's own pictures. See Its own look. - A mod holds at most 64 items. An item takes no other key. Reference: items.json, with every field, limit and error code. ## Which furniture can be a base of the game's pieces of furniture can be a base. The game refuses the others, and the Mods tab names the piece and the reason: Reason | Pieces | Which A piece "turns into a pocket item" when a player picks it up as an item rather than as furniture: umbrellas, fish, bugs, tools, balloons, fans, pinwheels and diaries. A piece that "takes a design" shows a player's own design. The pieces that can be a base, with the model viewer a click away to see each one's textures: ## Its own look Without textures an item looks exactly like its base. With it, the item draws pictures of its own on the base's model. Every other copy of the base keeps its look. A texture mod is different: its pictures change a texture everywhere it is drawn. items.json: ```json { "id": "ghost-lantern", "name": "Ghost Lantern", "base": "0x122C", "textures": "items/ghost-lantern/" } ``` - The folder holds 1 to 16 .png or .dds files. Subfolders count. - Each file is named after a texture of the base, the way a texture mod names its files: tex1_16x32_0d673c8f9b3a70fb_$_8.png. The textures guide explains the parts. The model viewer lists the base piece's textures under these names. - A picture whose name the base never draws does nothing. A texture of the base with no picture keeps its own look. - The folder may not be inside content.textures or hold it. There the pictures would be read as a texture mod and change every copy of the base. - The pictures count toward the same limits as a texture mod's: their decoded pixels and DDS bytes, and a PNG side of at most 2048. They are checked when you upload, and the reviewer sees them, like any picture in a mod. - Draw the pictures yourself. A recolour of the game's own texture is not your work. The upload refuses an unchanged copy of a game texture and shows the reviewer a close one. The item draws its own pictures in a house room and on Nook's floor. On Nook's floor every piece of that base is his good, so it shows the item's look. On the flower shop's bench, in the pockets and in the catalog an item is a leaf, as any furniture is. A piece outside, or the plain base piece a player keeps without your mod, has the base's look. A visitor sees your item's look when they have your mod too. A World mod always matches on a visit, so its items look the same for both players. Developer mode reads an item's pictures when the game starts. After you change one, restart the game to see it. ## Sell it The flower shop stocks your item by its full id. So can Nook's, in a furniture spot. Two goods of one shop may not use the same base. Only your own items go on the flower shop's bench this way. The game's own furniture has no shop table model, so the flower shop leaves it out. Nook's sells it. shops.json: ```json { "shops": { "nook": { "when": { "hours": { "from": "01:00", "to": "03:00" } }, "open": true, "own_goods": false, "goods": [ { "item": "example.after-hours:ghost-lantern" }, { "item": "0x1768" }, { "item": "0x1738" }, { "item": "0x16E4" }, { "item": "0x1780" }, { "item": "0x15BC" }, { "item": "0x15E0" }, { "item": "0x16C0" }, { "item": "0x16CC" }, { "item": "0x16FC" }, { "item": "0x16F0" }, { "item": "0x16B0" }, { "item": "0x1728" }, { "item": "0x1744" }, { "item": "0x1774" }, { "item": "0x1798" } ] } } } ``` On the shop's bench the item is a furniture leaf, as furniture off its spot always is. Joan calls it by your item's name. A shop changes what visitors see, so the mod must be a World mod ("scope": "world"). ## How it is kept - In the save, your item is its base piece, which is a real piece of the game. The save stays a plain game save that any tool and any visitor can read. - The record of which pieces are your items is kept beside the save. It travels with the cloud save. - With your mod, the item has its own name in the pockets and at the shop. - Without your mod, the player keeps the plain base piece. Nothing is deleted. When your mod comes back, the item has its name again. - A visitor without your mod sees the plain base piece. The City has no mod items. An item keeps its name in a house room and in the pockets, also when moved from slot to slot. It keeps its name as a letter's present too, through being attached, kept, mailed and taken out again. It becomes the plain base piece when it is stored in a drawer, dropped outside or mailed to a villager. A player can carry your item to The City or to a friend's town and back. Away from home it shows as its base piece. It has its name again when the player comes home, in whatever pocket it ended up in. An item sold, given away or put down while away is the plain base piece from then on. A piece bought away from home is never your item. Reference: mod-items.json (the game's), with what it records and where it goes. ## Renaming an item To rename an item in a new version, map the old full id to the new one. Players' pieces move over once per save. mod.json: ```json "renames": { "yourname.night-shop:lantern": "yourname.night-shop:ghost-lantern" } ``` Both ids must start with this mod's id. The new id must be an item in this mod's items file. A mod cannot rename another mod's items. --- ## Page: https://playaconline.com/modding/guides/more-targets/ ## Letters, calendar days and villager lines A mod changes each of these three parts of the game through a file of its own. The file is checked when the mod is installed and again when the game starts. ## What a mod can change A mod cannot patch any table in the game. It changes a fixed set of parts, each through its own file with its own rules. The rules keep saves and visits safe. Part | File | Scope Letters | content.letters | either Calendar days | content.calendar | world for a board notice, else either Villager lines | content.talk | either Nook's store: see the Shops guide. ## Letters A letters file holds letter templates. A script mails one with the send_letter command, as in cmd.send_letter{ template = "fair-thanks" }. Name the template by its id or by its full name, "your.mod:fair-thanks". A mod can send only its own letters. A calendar day can mail one with no script, see a day's letter. letters.json: ```json { "letters": [ { "id": "fair-thanks", "header": "Dear {player},", "body": "Thank you for coming to the\nHarvest Fair! Here is an apple\nfrom the prize table. Plant it\nand see what grows.", "footer": "The Fair Committee", "sender": "The Fair", "item": "0x2800", "paper": 12 }, { "id": "apple-day", "header": "Dear {player},", "body": "Happy Apple Day! Here is an\napple to share with a friend.\nOr plant it, and share the\ntree for years to come.", "footer": "The Harvest Post", "sender": "Harvest", "item": "0x2800", "paper": 12 } ] } ``` - A file holds 1 to 32 letters. Each has its own id of 1 to 48 characters from a-z, 0-9 and _ . -. - Letters are plain text. Use the letters, digits and signs on a US keyboard. $ * ^ | \ show as ?. - header is up to 24 characters, plus {player} once where the name goes. - body is up to 192 characters on at most 6 lines. The game wraps it at the paper's width in its own font. It refuses a body that then needs more than 6 lines. - The paper is 192 pixels wide and the font's letters are 4 to 10 pixels. Ordinary English fits about 30 characters a line. Narrow letters such as i, l and t fit more. Capitals, m and w fit fewer, and 19 W's fill a line. A word never splits, so a long word takes the next line whole. - A script may build the text from a name or a number. Keep such text under about 150 characters with no more than 5 line breaks, and try the longest case once. A body that does not fit is refused when it is sent. The Mod log gives the reason. - footer is the sign-off at the foot of the letter, up to 32 characters. - item is a present. Money, turnips, tickets and fossils are refused. - paper is the stationery, 0 to 63. - sender is optional, up to 8 characters. It is the name the mailbox list shows. The list has room for 8 characters only. Without a sender it shows the footer's first 8, so a footer of "The Lantern Keepers" reads "The Lant" in the list. The letter itself always signs with the whole footer. playac-mod check warns about a footer the list would cut. Reference: letters.json, with every field, limit and error code. ## Calendar days A calendar day is a date of your own. It can put a notice on the bulletin board and mail a letter, and talk pools can name it for villager lines on that day. The file's top-level key is "days": calendar.json: ```json { "days": [ { "id": "harvest-fair", "date": { "month": 9, "week": 3, "weekday": 3 }, "board": "HARVEST FAIR TODAY!\nBring your best fruit and\nshow it to your neighbours.\nThe biggest apple wins\nbragging rights for a year." }, { "id": "apple-day", "date": { "month": 10, "day": 21 }, "board": "APPLE DAY\nShare an apple with a friend\ntoday. Any apple will do,\nbut a red one says it best.", "letter": "apple-day" } ] } ``` - date is month and day. February 29 works. - date can also be month, week and weekday, for the nth such weekday of the month. Weekday 0 is Sunday and 6 is Saturday. "week": 2, "weekday": 5 is the second Friday, the one between the 8th and the 14th. "last" is the last one of the month. - The date is read from the town's clock, which is the device's clock. - board is a notice in plain text, like a letter body. It goes up once on the day, in the player's own town only. It never goes up on a visit or in The City. It changes the town, so the mod must be a World mod. - At most 3 notices go up on one day across every mod the player has. The first ones in load order go up. - On a full board, a notice first takes the place of a mod notice from an earlier day. It never pushes off a page dated today, so what the player wrote that day stays up. - Villager lines for the day are talk pools that name the day's id as their day, in any place of the talk. On the day, a day's pools come ahead of every pool kept to no day. A day with no notice and no letter is fine: it is a date for those pools. - letter is the id of one of your letters, as in "letter": "fair-thanks". The game mails it on the day with no script. It goes once per town that day, the first time the player is free in their own town. It never goes on a visit or in The City. It lands in the mailbox, or in the post office when the mailbox is full. It counts against your mod's 3 letters a day, like a script's send_letter. It needs no permissions. The Mod log says when it went out, or why not. - A day needs a notice, lines or a letter, or any of them together. Decorations are not offered, because the game's own decorations belong to the game's festivals. - A script calls game.calendar_today() to ask which of its own calendar days fall on the town's date. It returns a list of their ids, empty on other days. Reference: calendar.json, with every field, limit and error code. ## Test your day - The quick way. Set the day's date to today, install the mod and restart. Walk outside for the notice, talk to a villager and choose to chat a few times for the lines and check the mailbox for the letter. Put the real date back before you share the mod. - On its real date. The game takes the date from your device's clock when it starts. Set the clock forward, reload the game, then set it back. Your town lives through the jump as it would on a GameCube. Weeds grow and a villager may move out. Make a backup first with Export with mod data in the Save panel. - Installed in the middle of the day. The day still happens. The notice goes up the next time you walk outside in your town. The lines come in the next small talk, and the letter at the next moment you are free. A notice already on the board today is not posted again. - day_started runs once per day, when the town first reaches that date. It does not run again after a restart the same day. A script that reacts to a calendar day should call game.calendar_today() where it needs it, in villager_talked or scene_entered, and not only in day_started. - Every notice, letter and refusal is in the Mod log. ## Villager lines A talk file puts your lines in the villagers' talk, with no script. A pool's place says where: before the hello, as the hello, as the topic after a chat answer (small talk unless its topics say more), after the topic, or as the whole conversation. See places in a talk. talk.json: ```json { "pools": [ { "place": "topic", "personality": "cranky", "lines": ["Hmph. Another day of\nyou walking around.", "What now? I was just\ngetting comfortable."] }, { "place": "hello", "weather": "rain", "lines": ["Rain again. The flowers\nare loving it, at least."] }, { "place": "after", "season": "fall", "time": "evening", "chance": 30, "lines": ["The evenings come so\nearly now. I like it."] } ] } ``` - A pool names a personality, a villager by name, or neither. With neither, it is for everyone. The personalities are normal, peppy, lazy, jock, cranky and snooty. - season, time, weather and day keep a pool to a moment. Seasons are spring, summer, fall and winter. Times are morning, day, evening and night. Weather is clear, rain or snow. A day is the id of a day in your calendar file. - lines is 1 to 32 lines, each up to 160 characters with at most 3 line breaks, or a list of up to 8 such pages. - chance is in how many talks in 100 the pool's line is said, when the pool fits. The default is 100. The game picks each place's line like this: - A script's villager_talked line for the place comes first. - The most specific pools of that place that fit decide: a pool kept to today's calendar day first, then this villager by name, else their personality, else everyone. A pool fits when the season, time, weather and day it names are the ones now. - Each fitting pool rolls its chance. The lines of those that pass are put together and one is picked. When they all roll no, that part of the talk stays the game's. - Between mods, pools are not ranked by load order. The lines of every mod's fitting pools at the same level go in together. - Nothing is saved. A villager can say several of your lines in one day, and never the same line twice running when there is another. - A line never comes in a first meeting, an errand going with the player, a villager moving out or with an islander, and never in place of a first-job tip or the "should I move?" topic. - A script's villager_talked lines go by order: the first mod in the list to return a line for a place takes it. Shops are the opposite, where the lowest mod wins. See load order and two shop mods. The Lines guide has every rule. Reference: talk.json, with every field, limit and error code. The cookbook has two of these to copy. Harvest Post has calendar days and a letter. Springtime Town has talk pools. --- ## Page: https://playaconline.com/modding/guides/multiplayer/ ## Mods in friend visits and The City Players visit each other's towns and meet in The City. Your mod's scope decides what other players see. A World mod can also decide who can visit whom. ## Just you mods - A Just you mod ("scope": "client") changes only what its own player sees and hears. That covers textures, lines and scripts. - It never stops a visit, in either direction. Your friend sees their own game, without your textures. - It keeps running in a friend's town. It keeps running in The City too, unless The City has its own mod set. ## World mods - A World mod ("scope": "world") changes the town itself, so a visitor must see it too. - Only a World mod may hold a shop, a bulletin board notice, a script that sets the weather or a script that changes a shop. Use it too for textures you want everyone in your town to see. - A friend visit starts only when both towns have the same World mods that count, the same versions, in the same order. Two towns with none also match. - Mods are matched by their files, not by where they came from. Your ZIP and the copy from the mod list match when the files are the same. - Just you mods are not part of the match. ## Which World mods count This is the full rule. Other pages link here. - A World mod with "textures", "shops" or "items" content always counts. - A World mod with none of those does not count. That is a mod with only lines, letters, calendar days, talk pools or a script. - A script's commands do not make a mod count. A letter or an item is ordinary game state, and only its own player reads a line or a question. - A Just you mod never counts. A visitor sees its items as plain base furniture. - Every world setting of a World mod that counts is part of the match. A client setting is not: mark a cosmetic toggle "scope": "client" and two friends can visit with different choices. - A World mod that cannot load is not in that player's set, so the two towns differ. This happens when a mod it needs is missing or switched off. - A World mod that needs a Just you mod is the usual trap. See dependencies and visits. ## When the mods differ Both players are told what differs, for example: An older copy of the game cannot name the mods. It reads: The visit is refused before anything moves between the two saves. - If the host changes their World mods and restarts during a visit, the visit ends with the same message. - During a visit, Restart now in the Mods tab cannot be pressed. A visitor cannot change mods mid-visit by accident. ## Visiting with the host's mods A visitor can borrow the host's mods for one visit. This works when every World mod of the host that counts is a reviewed version from the mod list. A mod installed from a file cannot be lent. - A visitor who asks from the play page gets the offer. - The offer shows each mod's name, version, size and what it changes. It also shows when its scripts run and what its commands can do. - The game downloads each mod from the mod list and checks it against the host's copy by content hash. Nothing is installed. - The game restarts with the lent mods. The visitor's own World mods that count are off for the visit. Their other mods stay on. - If the visitor's game cannot load the whole set, the visit is called off and their own mods come back. A size limit or a mod the moderators removed can cause this. - When the visitor gets home, the game restarts with their own mods. A lent mod runs differently on the visitor's game: - Your scripts start with an empty store. Nothing they save is kept. - A lent mod acts only in the host's town. The visitor's game restarts at home before the trip and after it. There, the mod's shop, Nook goods, board notices, items and renames do nothing. Textures and lines still show. - At home, every command comes back refused with "a friend's mod lent for a visit acts only in their town". - A lent mod runs with the host's world settings. For a world setting, settings.get answers what the host picked, not the visitor's value or the default. - A client setting stays the visitor's own. settings.get answers the value on the visitor's installed copy of the mod, or the default when they do not have it. The host's value for it is never sent. - The values travel with the visit. They must be values your mod.json allows. They are never kept on the visitor's game. - A text setting the host changed from its default must pass the site's word checks. These refuse rude words, contact details and risky phrases. If a value fails, the visit is refused instead of lent. Keep text settings for short labels. Make a mod "world" only when it must be, and publish World mods on the mod list. Every World mod that cannot be lent is one more thing two friends must both have. ## The City - The City is a shared town everyone rides to. Anyone can go, whatever mods they have installed. - World mods' shops and bulletin board notices switch off there. Every player sees The City's own shops. - Mod items are off there, in any mod. The game neither names nor records them while you are in The City. - Every mod command is refused there. cmd.* answers nil with the code command-city. Mods can never put items into The City. --- ## Page: https://playaconline.com/modding/guides/scripts/ ## Lua scripts A mod script is written in Lua 5.4. It listens to game events and answers with data. For a talk, the answer is a line to say. A script can also read the pockets, the town and its villagers, and queue commands for letters, items, lines and questions. For a first script, start with the scripter path. ## Setting a script up In mod.json, name the file and list every event it listens to: mod.json (part): ```json "scripts": { "main": "main.lua", "events": ["villager_talked", "day_started"] } ``` - main must end in lower case .lua and be in the ZIP. It can sit in a folder, as in scripts/main.lua. - A mod has one script. There is no require, so keep your code in that one file. - events lists events, each once. Calling on() for an event that is not listed is an error. - A script works in a Just you mod and in a World mod. - A script that only offers functions to other mods still lists one event in events. List one and register no handler. See a library mod. Reference: main.lua, with every limit and error code. ## When your code runs - When the game starts, each mod's script runs from top to bottom once. This is where you call on() and set up your tables. - After that, only your handlers run, when their event happens. - Your variables keep their values for the whole session. They start fresh at the next restart. Use store for anything that must last. ## The API Call | What it does on(event, fn) | Runs fn each time event happens. Call it only while the script first runs, never from inside a handler. Up to 16 handlers per event. log(...) | Writes a line to the Mod log and the browser console as [Mods] your-id: .... Values are joined with spaces. A line is cut at 299 bytes. message(key) | Returns the line with that key from your messages file, or nil. With a colon, as in "other.mod:key", it reads another mod's line. game.time() | Returns the game's date and time as a table { year, month, day, hour, minute, weekday }. weekday is 0 for Sunday to 6 for Saturday. store.get(key) | Returns a saved value, or nil. store.set(key, value) | Saves a string, number or boolean. nil deletes the key. See the store. game.day_number() | Returns the game clock's day as one whole number, counted in days since 2000-01-01. store.town() | Returns an opaque text that names the town the store belongs to now, or nil before a town loads. When it changes, read again what you keep in locals. store.player.get, store.player.set | The store of the player who is playing. There is one per mod, per town, per player. See the store. store.client.get, store.client.set | The per-browser store. There is one per mod, whatever town is loaded. See the store. game.pockets() | Returns the held items only, in slot order, as { { slot, item, mod_item }, ... }. slot is 1 to 15. Empty pockets give {}. game.bells() | Returns the Bells in the wallet, or nil when no town is loaded. game.town() | Returns { name, id, year, month, day, hour, minute, weekday, season }, or nil when no town is loaded. season is spring, summer, fall or winter. game.villagers() | Returns { { id, name, species, personality }, ... }. personality is normal, peppy, lazy, jock, cranky or snooty. Every villager is on the villagers list. game.player() | Returns { name, id, x, y, z, angle, acre, scene, tool, state }, or nil when no town is loaded. id stays the same for that resident in that town. The rest says where the player stands and what they are doing. See the player. game.weather() | Returns the weather where the player is, { kind, intensity }, or nil when no town is loaded. See the weather and where the player is. game.place() | Returns where the player is, { scene, name, island, acre, acre_x, acre_z, unit_x, unit_z }, or nil when no town is loaded. See the weather and where the player is. game.calendar_today() | Returns the ids of your own calendar days that fall on the town's date today, in file order. It returns {} when there are none. See calendar days. game.input() | Returns the player's buttons held now and the main stick: { a, b, ..., c_right, stick_x, stick_y }. See the player's buttons. settings.get(name) | Returns a setting's value. That is the player's value, or the default. See settings. remote.add, remote.call, remote.has | Offer functions to other mods and call theirs. See dependencies. remote.version | Whether a mod named in depends or optional_depends is there, and at what version. See optional dependencies. rng(), rng(n), rng(m, n) | Return a random number. rng() gives a fraction from 0 up to 1. rng(n) gives a whole number from 1 to n. rng(m, n) gives one from m to n. See random numbers. timer.after(minutes, name, data) | Sets a timer that fires once, as a timer_fired event, that many game minutes from now. It returns the timer's id. See timers. timer.cancel(id) | Cancels a waiting timer. It returns true when there was one. cmd.* | Queues a command. See Commands. ## Events Every handler gets exactly one table, e. A field with nothing to say is nil, never an empty string or 0. Ids are always numbers in Lua. JSON files write them as strings such as "0x2800". cmd.* takes a number, "0x2800" or your mod's own "author.mod:thing". Event | e | Return | When villager_talked | { villager } | nil, a talk table { place, line, topics, ask }, or a list of talk tables. | The player starts an ordinary talk with a villager. See the places. day_started | { year, month, day, weekday } | Nothing | A new day begins in the game. item_picked_up | { item, mod_item } | Nothing | The player got an item. scene_entered | { scene, name } | Nothing | A scene starts, such as the town, a house or a shop. data_migrated | { from, to } | Nothing | Fires once per town, when mod.json "data_version" differs from the version the town's data was written at. See moving your data forward. hour_changed | { year, month, day, hour } | Nothing | The game's clock reached a new hour. item_bought | { item, mod_item, price, shop, ordered } | Nothing | The player bought a good for Bells at any counter in the game. See the shops. item_sold | { item, mod_item, count, bells, shop } | Nothing | The player sold for Bells. See the shops. fish_caught | { item, pocketed } | Nothing | A fish was landed. bug_caught | { item, pocketed } | Nothing | A bug was netted. letter_read | { sender, item, mod_item, first_time, letter } | Nothing | The player chose Read on a letter. villager_moved_in | { villager } | Nothing | A villager with no house was given one. visitor_arrived | { kind } | Nothing | A friend is riding into this player's own town. command_finished | { id, command, ok, via, code, message } | Nothing | A command this mod queued was applied or refused. question_answered | { id, choice, text } | Nothing | The player answered this mod's ask, or closed it. timer_fired | { id, name, data } | Nothing | A timer this mod set with timer.after is due. See timers. villager_answered | { villager, choice, text } | nil, a line, or a reply table { line, ask }. | The player answered the question this mod's conversation asked (villager_talked returned place = "conversation" with an ask). See a conversation that asks. button_pressed | { button } | Nothing | A button on the player's controller was pressed. See the player's buttons. button_released | { button } | Nothing | A button on the player's controller was let go. See the player's buttons. player_acted | { action, item, reaction } | Nothing | The player started one of the actions below. See the player. Notes on the fields: - villager is the same table wherever a villager appears, in events and in each entry of game.villagers(). It is { id, name, species, personality }. id is a number that stays the same for that villager. species and personality are nil when the game cannot tell. - In scene_entered, scene is the scene number. name is its name from the scenes list, like "player_house". It is nil for a scene with no published name. - In letter_read, item is the present. It is nil when there is none. - In letter_read, letter names the letter when a mod's letters file sent it. It is the full id, like "your.mod:welcome". To act when the player reads your invitation, test e.letter == "your.mod:welcome". It is nil for the game's letters, a player's letters and a letter sent with cmd.send_letter{ text }. The game finds the letter by its words, so two letters with the same body and sign-off are not told apart. - mod_item is the full id of a mod item, like "your.mod:ghost-lantern", when the piece is one. item is then the furniture it stands on. For item_sold, it describes the first piece sold. mod_item is nil for a plain good. It is also nil for a visitor shopping in a friend's town, whose piece is plain furniture. - item_picked_up carries mod_item when you pick a mod item up off the floor of your own house. That is the only place a mod item stands. A mod item dropped outdoors is plain furniture, so it comes back plain. - letter_read carries mod_item when the letter's present is a mod item, such as one you attached to a letter yourself. - fish_caught and bug_caught have no mod_item. A fish or a bug is never a mod item. - fish_caught has no size or length, because the game keeps none for a caught fish. Each kind of fish has one shadow size, so item tells you that. - In item_picked_up, write item numbers in hex to match the game's lists, with string.format("0x%04X", e.item). - item_picked_up does not fire for anything bought. It also does not fire when the pockets are full, because the item is not yours yet. - A fish or a bug that goes into the pockets fires item_picked_up and then fish_caught or bug_caught. A script that counts in both handlers counts that catch twice. Count catches in fish_caught and bug_caught, where pocketed says whether it was kept. Or skip fish and bugs in item_picked_up. Notes on villager_talked: - Use it for a line that depends on something, such as the time, the date, the store or an item in the pockets. The script kit has a villager notice an apple you carry. Small talk needs no script: put it in a talk pool, by villager or personality, season, time of day, weather and calendar day. - Every line names its place: a plain string returned alone is refused and logged. A talk table names its place: before, hello, topic, after or conversation, and its line is a string or a list of up to 8 pages. Return a list of talk tables for several places at once. See any place from a script. - A conversation can end in ask = { text, choices }. The pick goes to your villager_answered handler, which returns what the villager says next. See a conversation that asks. - A place a script did not take can still get a calendar day or talk pool line, so one talk can have both. - It is never called for a special talk. Special talks carry the game's own story, so no mod hears them. They are a first meeting, a villager moving out, an errand, delivery or contest in progress with that villager, a complaint, a pitfall or a bee chase, an islander, Kamakura and summer camp. - The villager's next ordinary talk calls villager_talked as usual. A line you keep for "the next time we talk", such as a thank-you, comes then. - The game asks every mod in the order of the Mods tab list, from the top. The first line returned for a place takes it; a later one for that place is written to the Mod log. A conversation takes the whole talk, and the mods below it are not asked. - A page is 1 to 400 bytes, with no zero byte. Returning "" or nil means no line. A table that is not right is written to the Mod log and nothing of it is said. Notes on item_bought and item_sold. shop says where: shop | Where "nook" | Nook's in every size, and Nookington's in The City "flower" | The flower shop "redd" | Crazy Redd "saharah" | Saharah's carpet, swapped for one of yours plus Bells "joan" | Turnips "fireworks" | The fireworks show's stall "shrine" | The New Year fortune slip "gyroid" | What another player put up at their gyroid "villager" | A villager's trade - Only Nook's and villagers buy from you. To keep to Nook's, test e.shop == "nook". - ordered is true for a Nook's catalog order. It is paid now and mailed tomorrow, so it is not in the pockets yet. - A service is not a good and sends no item_bought. Services are a new look at the Pampered Paw (the haircut service), Katrina's fortune, a dream and an Able Sisters design. Notes on timing: - day_started does not run again when the game restarts later on a day the town already saw. The save holds the day it last began. - If the game was not saved since that day began, the save still holds the day before. The next start then runs day_started again. To count days, store the last date you saw instead of counting calls. - No event runs in the title screen demo. ## The player game.player() reads the player as they are right now, so it is cheap to call from any event or timer: - x, y, z: where they stand. A ground tile is 40 across and an acre is 640. x grows to the east and z to the south, down the screen. Inside a building they are the room's own. - angle: which way they face, 0 to 359 degrees. 0 faces south, toward the camera, 90 east, 180 north and 270 west. - acre: { x, z } in the town, as the map counts acres. x is the column, 1 to 5 from west to east. z is the row, 1 (the train station's row, A on the map) to 6 (the beach row, F). It is nil in any scene but the town. - scene: the scene's name from the scenes list, like "town". - tool: "axe", "net", "rod", "shovel" or "umbrella" in their hand, golden ones too. nil for an empty hand or anything else. - state: one word: "standing", "walking", "running", "sitting", "lying" (on a bed), "wading" or "busy". "wading" is the game's word for walking into the next acre while the screen scrolls: the town has no water a player can wade into. "busy" is everything else: a tool swing, picking something up, a talk, a door, a cutscene. Treat a word you do not know as "busy": the list may grow. Everything after id is nil while the scene is still being built, such as in day_started as the game starts. On a visit it is the visitor, standing in the host's town. main.lua: ```lua local p = game.player() if p and p.scene == "town" and p.acre then log("in acre", p.acre.x, p.acre.z, "facing", p.angle, "holding", p.tool or "nothing", "and", p.state) end ``` player_acted fires when the player starts an action. e.action is one of axe_swung (at a tree or at nothing), axe_hit_rock, axe_broke, net_swung, rod_cast, shovel_dug, hole_filled, tree_shaken, sat_down, stood_up, lay_down, stung, fell_in_pitfall, tripped, shocked, door_entered or reacted. It arrived in API 1.1. - Walking, running and standing are never events. Read game.player().state for those. - item is the tool's item number for an axe, net, rod or shovel action. An axe's number changes as it wears. It is nil for every other action. - reaction names the reaction for reacted: one played from the reactions bar or by cmd.react. - It is the start, not the result: axe_swung fires for every swing, whether the tree falls or not. - Only the player playing this game sends it. A friend on a visit or another player in The City does not. - It fires on a visit and in The City too, where it changes nothing. - A word you do not know may come in a later update: ignore it. cmd.react(name) plays a reaction on the player's own character. See the commands. The player is busy with the action that just started, so react a moment later, from a timer: main.lua: ```lua -- Count the trees shaken today, per resident, and cheer on the tenth. on("player_acted", function(e) if e.action ~= "tree_shaken" then return end local n = (store.player.get("trees") or 0) + 1 store.player.set("trees", n) -- The player is busy shaking the tree right now, so cheer a minute later. if n == 10 then timer.after(1, "cheer") end end) on("timer_fired", function(e) if e.name == "cheer" then cmd.react("hooray") end end) ``` ## Small examples Say something different on Sunday mornings: main.lua: ```lua on("villager_talked", function(e) local t = game.time() if t.weekday == 0 and t.hour < 12 then return { place = "before", line = "A lazy Sunday morning, " .. e.villager.name .. " says. Isn't it lovely?" } end return nil end) ``` Count every item you pick up, across sessions: main.lua: ```lua on("item_picked_up", function(e) local n = (store.get("picked") or 0) + 1 store.set("picked", n) if n % 100 == 0 then log("you have picked up", n, "things") end end) ``` The cookbook has whole mods to read. ## The store - store is one per mod per town, with 8 KB per town. store.client is one per browser. - The main part of your script runs before a town loads, so read and save from events. See Per-town data. - A town has up to 4 residents, and they share store. store.player is one per mod, per town, per player. Keep there anything one resident earns alone, such as a quest or today's gift. It takes the same keys and values and lives inside the same 8 KB. - When a resident is deleted, the game deletes what your mod saved for them in store.player. A new resident in that save slot starts with nothing. - Every store.set, store.player.set and store.client.set writes your mod's file in the save folder before it returns. - The browser keeps the save folder at the game's next save sync. That is a game save. For the cloud, mod data uploads at most every 2 minutes. A tab closed before that sync loses the last sets. - A key is a string of up to 64 bytes. It cannot start with a control character. - A value is a string of up to 1024 bytes, a number, true or false. Whole numbers come back whole. - A store.set that breaks a limit changes nothing and raises an error. The error stops your script unless you catch it: main.lua: ```lua local ok, err = pcall(store.set, "notes", long_text) if not ok then log("could not save notes:", err) end ``` ## Timers A script cannot wait. It asks to be called later: timer.after(minutes, name, data) sets a timer, and the game sends your mod a timer_fired event when it is due. main.lua: ```lua -- mod.json: "events": ["villager_talked", "timer_fired"], -- "permissions": ["show_line"] -- The mark is in the town's store, not store.player: the timer can fire -- while another resident plays, and it must be cleared then too. on("villager_talked", function(e) if store.get("kettle") then return nil end local id, why, code = timer.after(30, "kettle", e.villager.name) if not id then log("no timer:", why, code) return nil end store.set("kettle", id) return { place = "before", line = "I put the kettle on. Come back in half an hour!" } end) on("timer_fired", function(e) -- e = { id, name, data }: the timer is already gone if e.name == "kettle" then store.set("kettle", nil) cmd.show_line("The kettle at " .. e.data .. "'s place must be boiling by now.") end end) ``` - List timer_fired in scripts.events and add its handler. Without a handler, timer.after is refused. - minutes is a whole number of game minutes, 1 to 10,080. That is up to 7 game days. - name says what the timer is for. It is 1 to 40 bytes of letters, digits, _, - and .. One handler gets all your timers, so test e.name. - data is optional. It is text of up to 240 bytes, a number, true or false. It comes back as e.data. Empty text comes back as nil. - timer.after returns the timer's id. An id is never used twice in a town. When it is refused, it returns nil, a message and a code. - timer.cancel(id) cancels a waiting timer and returns true. It returns false for a timer that already fired. The clock: - Time is counted on the game's clock, the one game.time() reads. A timer keeps counting while the game is paused or closed. - A timer fires at the end of a frame's update, in whatever scene the player is in. One that came due while the game was closed fires soon after the town loads. - A timer never fires at the title screen or at player select. Nothing of a mod runs there: no event, no timer and no command. It all carries on when play starts. - The smallest step is one game minute. A timer never fires early. - If the player sets the game's clock forward, every timer that is now due fires. If they set it back, a timer waits again, but never longer than 10,080 minutes from the new time. Where a timer is kept: - A waiting timer is kept in your mod's town store. It survives a save and a reload, and it travels with the town in a cloud save or an export. - It counts toward the store's 8 KB, with its name and data. A timer that does not fit is refused. - A mod may have 16 timers waiting in one town. - The main part of your script runs before a town loads. Set timers from events. - On a visit and in The City, the store lives in memory, and so do timers set there. They are gone when the player leaves. - A scene change does not touch a timer. Limits when a timer fires: - timer_fired is an event like any other. Its handlers share the usual budget of 200,000 instructions. - Commands queued from it count against the caps per event and per day, as from any event. - At most one timer per mod fires in a frame. When several are due, the rest fire in the next frames, earliest first. - The timer is gone before your handler runs. To repeat, set the next one inside the handler. Code | Try again | When timer-args | never | Wrong arguments, such as the minutes, the name or the data. Also when the script has no timer_fired handler. timer-limit | later | The mod already has timers.per_mod timers waiting in this town. timer-no-town | later | No town is loaded yet. The script's main chunk runs before the save loads. timer-no-clock | later | The game clock is not set. It reads a date before the year 2000, so there is no minute to count from. timer-store-full | later | The timer does not fit in this mod's town store (store.bytes), or the store could not be written. ## The player's buttons A script can read the controls the player plays with. A keyboard key, a controller button and the on-screen touch pad all reach the game as the same controller, with the player's own key settings applied, so one handler covers all three. The Button Tricks example gives each D-pad button a trick of its own. main.lua: ```lua -- mod.json: "events": ["button_pressed"], "permissions": ["show_line"] on("button_pressed", function(e) -- Z while L is held: a combination the game itself does not use local input = game.input() -- nil while the text editor is open if e.button == "z" and input and input.l then cmd.show_line("Hotkey!") end end) ``` - The buttons are a, b, x, y, z, l, r, start, dpad_up, dpad_down, dpad_left, dpad_right, c_up, c_down, c_left and c_right. The C stick is the four c_ buttons. - The two events and game.input() arrived in API 1.1. A playac-mod older than 1.1.0 does not know them. - button_pressed and button_released hand you { button }. They come once a frame, releases first, each in the order above. - A button already held when play starts, or held through a change of scene or the text editor, is not a press. - game.input() gives every button as true while held, and the main stick as stick_x (right) and stick_y (up), each from -1 to 1. The keyboard's movement keys tilt it fully. - The game still gets every press. A button your handler listens to does what it always does too, so pick a combination the player does not use for anything else. - Your script never sees which key was typed. Nothing reaches it while the game's text editor is open, such as writing a letter or a name, whether by keyboard or by controller. game.input() answers nil then. ## The weather and where the player is Two questions a script can ask at any time, from any event. Asking changes nothing, so they need no permission. main.lua: ```lua -- mod.json: "events": ["scene_entered"], "permissions": ["show_line"] on("scene_entered", function(e) if e.name ~= "town" then return end local w, p = game.weather(), game.place() if not w or not p or not p.acre then return end if w.kind == "rain" and w.intensity == "heavy" then cmd.show_line("Pouring at " .. p.acre .. ". Good day for fish.") end end) ``` - game.weather().kind is clear, rain or snow, the same words shops and talk pools use. Cherry blossom petals and falling leaves count as clear. - intensity is light, normal or heavy for rain and snow, and none when it is clear. - Indoors, game.weather() is the weather outside. On the island it is the island's, which can differ from the town's. - game.place() gives scene and name as scene_entered does, and island, true on the island or in a cottage there. - Outdoors it adds the acre. acre is the town map's own label, from "A-1" to "F-5", or "island-1" and "island-2" on the island. acre_x is the column and acre_z the row, 1 for A. unit_x and unit_z are the square inside the acre, 0 to 15 from the north-west corner. Indoors these are nil. - game.place() names a place the way the town map does, to one square. For the exact position, use game.player(). Both are only ever the player's own: a mod never sees where another player is. - On a visit, both describe the town being visited, the one game.town() names. ## Random numbers - rng() counts how many numbers your mod has drawn in this town on this game day. Each call gives the next one, so calls in a day differ. - The count is saved with the town. A reload carries on from it, so reloading cannot reroll. A new game day starts new numbers. - On a visit, in The City and before a town loads, the count is kept in memory only. - math.random and math.randomseed are not available. Calling one stops the script with an error that says to use rng(). ## What Lua you get - You get Lua 5.4 with the string, table, math, utf8 and coroutine libraries. - You get the basic functions, such as pairs, ipairs, tostring, tonumber, type, select, pcall, error and setmetatable. - These are not there: io, os, debug, package, require, load, loadfile, dofile, collectgarbage, print and string.dump. Use log in place of print. - __gc metamethods are refused. A table with a __len metamethod cannot be passed to table.insert, remove, sort or concat. - For random numbers, use rng. ## Limits and what happens past them Limit | Value Work per event | 200,000 Lua instructions for all your mod's handlers of that event together. Library work counts too. That covers string patterns, table sorts and joins, string.pack and unpack at 1 instruction per 4 format bytes, and memory you allocate. Time per event | A backstop: one event run past 125 ms stops the script. 3 runs in a row over 8 ms stop it too. Both are stretched on a slow device. See what stops a script. Time at start | A backstop: the main part of the script, when the game starts, gets 250 ms. Memory | 4 MB per mod, 16 MB for all mods together Handlers | 16 per event per mod log() | 20 lines per event and 500 per session. Past that, lines are dropped with a note. Script file | 512 KB A script that raises an error, runs out of memory or runs past its time is stopped for the rest of the session. Your mod's other content, such as textures and a shop, keeps working. The Mods tab shows Script stopped: and the reason, for example yourname.my-script/main.lua:12: attempt to index a nil value. The same line goes to the console. pcall catches ordinary errors, but never a stop for running too long. Keep handlers short. Answer from data you prepared when the script started. A loop over thousands of items on every talk is the usual way to hit the time limit. ## What stops a script, and what does not - The instruction count is the rule. A run that goes past 200,000 instructions is stopped with script took too long (over 200000 instructions). The count is the same on every device. An endless loop and a huge allocation are stopped this way, on a fast computer and on a slow phone alike. - Wall-clock time is only a backstop. Some work happens inside one instruction, such as a garbage collection. The count cannot see that time, so a run past 125 ms is stopped too, with script took too long (over ... ms). A script that stays inside its count does not get near it. - Slow runs. A run over 8 ms is a strike. 3 strikes in a row stop the script with script kept the game waiting. One fast run clears the strikes, so one pause of a busy device is not enough. - A slow or busy device. The game measures how long its own work takes each frame, without the mods' time. When its frames are slower than usual, the wall-clock limits above are stretched by the same factor, up to 8 times. So a phone, or a computer busy with other programs, does not stop a mod that a fast computer runs. The message shows the stretched number. - The frame share never stops a mod. All mods together get 4 ms of Lua a frame. Past that, events wait for the next frame, in order, and a talk is answered by the villager's own line. On a slow device events wait more often, but they still run. ## What a script cannot do - It cannot change anything in the game directly. A handler only returns data and queues commands. The game applies them at the end of a frame's update, within the mod's permissions and caps. Moving villagers or reshaping the town is not a command. - It cannot run every frame. There is no per-frame event, and there will not be one. A timer waits at least one game minute. - It cannot take anything from the player on its own. cmd.take_item and cmd.take_bells only ask, in the game's own words, and the player decides. See taking items or Bells. - It cannot write the player's save on its own terms. cmd.save() asks the game for the same save the Autosave setting makes, and the game writes it only outdoors in the player's own town, in free control. See saving the game. - It cannot make any weather it likes. cmd.set_weather asks for weather the game itself could have on that date, and the game changes it as it does on its own. See the weather. - It cannot read files or reach the internet. It cannot see the page, the player's account or other mods' variables. - It cannot load more code or compiled Lua. The reference lists every event, query and command. --- ## Page: https://playaconline.com/modding/guides/settings/ ## Settings and per-town data A mod can offer settings the player changes on the Mods tab. Its script can keep data per town. ## Settings Declare up to 16 settings in mod.json. The Mods tab shows them on your mod's row under Settings. Your script reads them with settings.get(name). mod.json: ```json "settings": [ { "name": "greet", "type": "bool", "label": "Say hello", "default": true, "scope": "client" }, { "name": "price", "type": "number", "label": "Fruit price", "description": "Bells per fruit.", "default": 600, "min": 100, "max": 5000 }, { "name": "drink", "type": "choice", "label": "Drink", "default": "tea", "choices": ["tea", "coffee"] }, { "name": "motto", "type": "text", "label": "Shop motto", "default": "", "max_length": 40 } ] ``` main.lua: ```lua on("villager_talked", function(e) if not settings.get("greet") then return nil end return { place = "before", line = "Fruit is " .. settings.get("price") .. " Bells today!" } end) ``` - name is 1 to 32 characters from a-z 0-9 _, starting with a letter. - label is 1 to 60 characters. description is up to 200. - bool has a default of true or false. - number has whole numbers for min, max and default. - choice has 2 to 16 choices and a default that is one of them. - text has a max_length of 1 to 200 and a one-line default. - The game reads settings when it starts. A change is used from the next start, like every mod change. - A signed-in player's settings follow their account to their other browsers and devices, with the mod. On the other device, each value goes through the same checks as a change in the Mods tab. It is always a value your declaration allows. - A setting can say whose it is on a friend visit, with "scope". See the next section. ## World settings and client settings A setting is "scope": "world" or "scope": "client". A setting with no scope is a world setting. | World setting | Client setting Whose it is | The town's. | The player's own. A friend visit | Compares it. Both towns need the same value. | Never compares it. A visitor who borrows the host's mods | Plays with the host's value. | Keeps their own value. It is the one set on their installed copy of the mod, or the default when they do not have the mod. Leaves the browser | Yes, on a visit, to the friend. | No. It is never sent on a visit. What the Mods tab says under it | "Part of your town." | "Just for you." - Use client for a choice that only changes what its own player sees or hears: whether a villager says your line, which wording, a display choice. - Use world, or no scope, for anything that decides what the town gets or gives up: what a letter says or carries, what is given or taken, when. - On a visit, the scope matters only for a World mod that counts. A visit never looks at a Just you mod. - The rule below holds on every mod, a Just you mod too. Leave scope off a setting that decides what is sent, given or taken. - A World mod with only client settings matches a friend's copy whatever each of them picked. ## What a client setting may decide A client setting may not decide what the town gets. The game checks this one event at a time. In an event that read a client setting with settings.get, cmd.send_letter, cmd.give_item, cmd.take_item and cmd.take_bells are refused. The call returns nil, a message and the code command-client-setting. cmd.show_line and cmd.ask still work, because only the player sees them. refused: ``` -- "gift" is a client setting: this give_item is refused on("day_started", function(e) local id, why, code = cmd.give_item(settings.get("gift") == "pear" and 0x2802 or 0x2800) -- id is nil, code is "command-client-setting" end) ``` fine: ``` -- "hello" is a client setting: it only decides what this player hears on("villager_talked", function(e) if settings.get("hello") == false then return nil end return { place = "before", line = "Fruit is " .. settings.get("price") .. " Bells today!" } end) ``` - The check covers one event. The next event starts clean. - The game cannot follow a value you keep. If you store a client setting in a variable, in store or in a timer's data and use it in a later event to send, give or take, nothing refuses it and nothing warns you. - timer.after is not refused after a client setting was read. A timer that shows its player a line later is a proper use of one. - What you would see then: your town gets what your value says, because only the town owner's game changes a town. A friend's copy of the mod runs their value. Its lines can then describe a gift or a letter that does not match what your town got. - The same holds for a client value handed to another mod through remote.call. - playac-mod check warns when a script reads a client setting and also sends, gives or takes anywhere. ## Per-town data - store is kept per town. Each mod has 8 KB per town. - The store travels with the town in its cloud save and backups, and in Export with mod data under the save button's More options. It is never written into the save file itself. - store.player is one per mod, per town, per player. A town has up to 4 residents, and they share store. Keep in store.player what one resident earns alone. It lives inside the same 8 KB. - game.player().id is the number that tells residents apart. - When a resident is deleted, the game deletes what your mod saved for them in store.player. That room goes back to your 8 KB. - A new resident in that save slot starts with nothing. The game can give them the id the deleted resident had, so do not treat an id as proof of who a resident was. - store.player.set needs a player in the game. With a town loaded and no player yet, game.player() is nil, store.player.get returns nil and store.player.set raises an error. - store.client is one per browser, whatever town is loaded. - Every store.set, store.player.set and store.client.set writes your mod's file in the save folder before it returns. - The browser keeps the save folder at the game's next save sync. That is a game save. For the cloud, mod data uploads at most every 2 minutes. A tab closed before that sync loses the last sets. - The main part of your script runs before the town loads. There, store.get answers nil and store.set is refused. Read and save from events. - store.town() tells you which town the store belongs to. Use it to reload what you keep in locals when the player moves to another town. - On a visit to a friend's town and in The City, store starts empty and is not kept. - A browser keeps mod data for 16 towns. A 17th drops the data of the other town that was written least recently. - Removing a mod asks the player whether to keep its data or delete it. Installing the mod again finds data that was kept. main.lua: ```lua -- what you keep in locals is read at the first event in each town local town, days = false, 0 local function fresh() if store.town() == town then return end town = store.town() days = store.get("days") or 0 end -- day_started can fire twice for one day when the game was not saved, so -- count a day by its date, not by the call on("day_started", function(e) fresh() local today = string.format("%04d-%02d-%02d", e.year, e.month, e.day) if store.get("last_day") ~= today then store.set("last_day", today) days = days + 1 store.set("days", days) -- this town's store end store.client.set("seen", true) -- this browser's, whatever town end) ``` ## Moving your data forward When you change the shape of what you save, raise data_version. In each town the game calls your data_migrated handler once. e.from is the version the town's data was saved at, and e.to is the new one. It does not run at the restart. It runs as the town loads, before any other event in that town. mod.json: ```json "data_version": 2, "scripts": { "main": "main.lua", "events": ["data_migrated", "day_started"] } ``` main.lua: ```lua on("data_migrated", function(e) -- version 1 kept "n" as text; version 2 keeps a number if e.from < 2 and type(store.get("n")) == "string" then store.set("n", tonumber(store.get("n")) or 0) end end) ``` - data_migrated runs only for data that exists. On a fresh install, or in a town where your mod never saved anything, it is not called. Your first store.set writes the data at the current data_version. - from is 0 for data saved before you set a data_version. - If the handler raises an error, your script stops for the session and the version stays. The next start tries again. - Mods migrate one after another in load order. Inside data_migrated, change only your own data. A remote.call into a mod whose own migration has not run in that town yet is refused. --- ## Page: https://playaconline.com/modding/guides/shops/ ## Shops A shop mod changes the game's shops: Nook's store, the flower shop, the visiting sellers and the shops that sell a service. Every shop takes the same block: your goods, prices, opening, and when it all applies. The writer path starts you with a kit. ## One file, every shop Every shop of a mod goes in one file, shops.json. Its mod.json names it as content.shops. A shop changes the town for visitors, so the mod must be a World mod ("scope": "world"). - shops is an object. Each key is a shop's id from the shop table, like "nook" or "flower". A key that is not a shop id is refused, and the message suggests the id you meant. - A shop's value is one block, or a list of 1 to 8 blocks. See several blocks. - A mod changes a shop with one key, so a shop can never be listed twice. The shop kit's mod.json: mod.json: ```json { "schema": 1, "api": 1, "id": "yourname.my-shop", "name": "My Shop", "version": "1.0.0", "authors": ["yourname"], "description": "The flower shop with my own name, lines and goods from 9:00 to 21:00, and two goods of my own at Nook's.", "scope": "world", "content": { "shops": "shops.json" }, "assets_original": true } ``` And its shops.json, which changes the flower shop and adds two goods at Nook's: shops.json: ```json { "shops": { "flower": { "when": { "hours": { "from": "09:00", "to": "21:00" } }, "own_goods": false, "goods": [ { "item": "0x2900", "price": 500 }, { "item": "0x2908", "price": 300 }, { "item": "0x2905", "price": 300 }, { "item": "0x2902" } ], "name": "My Shop", "lines": { "greeting": "Hello and welcome! Have a look around.", "stock": "Saplings and seeds today. Point at one and I'll tell you the price." } }, "nook": { "goods": [ { "item": "0x1110", "price": 1800 }, { "item": "0x2205", "price": 900 } ] } } } ``` ## The block A block holds any of "when", "open", "own_goods", "goods", "price_percent", "buy_back_percent", "services", "name" and "lines", and at least one of them besides when. Each field means the same on every shop. Field | Who has it | Rule when | every shop | When the block applies. Leave it out for always. See when. open | Nook's store, the flower shop and the barber shop | true: the shop is open while the block applies, also when its own hours have it shut. false: it is shut while the block applies. Leave it out for the shop's own hours. own_goods | Nook's store, the flower shop, Crazy Redd's tent, Saharah and the fireworks stall | true, the default: your goods join the shop's own, in at most half the spots of their kind, rounded up. false: the shop sells only the goods of the blocks that apply, and every spot of a kind they do not list is bare. The game's own event days still show: see event days. goods | Nook's store, the flower shop, Crazy Redd's tent, Saharah and the fireworks stall | 1 to the shop's goods limit in the table. Each good is { "item", "price", "when" }, with price and when optional. No item twice in a block. item | in goods | The item number as a string: "0x" and 4 hex digits, such as "0x2900". At Nook's and the flower shop it can also be one of your own mod items by its full id. price | in goods | A whole number of Bells, 1 to 99999. Leave it out for the shop's own price. See prices. when | in goods | Narrows one good further: it shows while its block's when and its own both hold. price_percent | Nook's store, the flower shop, Crazy Redd's tent, Saharah and the fireworks stall | 1 to 1000. The shop asks this percent of its own price for every good with no price of its own. 100 is the game's price. At Nook's, grab bags and Halloween candy keep the game's price. buy_back_percent | Nook's store | 1 to 1000. Nook pays this percent of what he would pay for what the player sells, never more than he asks for the item at that moment. Not turnips. services | Able Sisters, the barber shop, the Dream Suite and Katrina's tent | A service's price in Bells, 1 to 99999, by the service's name in the table. A name the shop does not have is refused. name | the flower shop | 1 to 40 characters on one line. The flower shop shows it on the sign by the door while it is shut. lines | the flower shop | What the keeper says, by slot. A slot is one line, or a list of 1 to 8 lines, and the keeper picks one each time. Each line is 1 to 160 characters, at most 3 line breaks. A slot the shop does not have is refused. A field a shop does not have, such as name at Nook's, is not refused. The game leaves that field out and applies the rest of the block, and your mod's row in the Mods tab names the shop and the field (shop-field-ignored). Reference: shops.json, with every field, limit and error code. ## When a block applies A when holds any of "hours", "time", "season", "weather", "weekday", "month" and "setting". The block applies while every key in it holds. Leave when out and the block always applies. Key | Holds hours | { "from": "HH:MM", "to": "HH:MM" } on the 24 hour clock, two digits each: write "09:00", not "9:00". From the first time up to the second. They must differ. to may be past midnight, such as 23:00 to 03:00. time | "morning" 5 to 12, "day" 12 to 17, "evening" 17 to midnight, "night" midnight to 5. season | "spring" March to May, "summer" June to August, "fall" September to November, "winter" December to February. weather | "clear", "rain" or "snow". Cherry blossom and falling leaves count as clear. weekday | A list of days, "monday" to "sunday", each once. month | A list of months, 1 (January) to 12, each once. setting | The name of one of your mod's settings of type bool with scope world. Holds while it is on. ## When a change shows - A block with a when applies at once. The moment its when holds, the shop has the block's goods, prices and opening. Walk in and they are there. That holds at Nook's and at every other shop. At Nook's the game's event days stay as they are: see event days. - At Nook's, the goods of a block with no when show from the next restock. A when on any one of its goods counts as a when. Nook sets out each day's goods the first time the town is played on that day at or after 6:00 AM, and the block's goods and its own_goods go into that day's stock. A mod installed at noon shows its goods the next morning. - Everything else applies at once, with or without a when: every other shop, and Nook's open, price_percent and buy_back_percent. ## What each shop has The shop table is read from the game. Each shop takes the fields in its row. Nook's store, the flower shop, Crazy Redd's tent, Saharah and the fireworks stall sell goods. Able Sisters, the barber shop, the Dream Suite and Katrina's tent sell a service. Only the flower shop take lines. Shop id | Fields it has | Goods in a block | Services, line slots | Spots | open "nook", Nook's store | when, open, own_goods, goods, price_percent, buy_back_percent | 1 to 16 | none | Spots by kind (furniture, stationery, clothing, carpets, wallpaper, tools, umbrellas, paint, saplings, flower bags), more in a bigger store. A new set of goods is picked each day when a block lists more than the spots. | open: true opens it when it is shut for the night, but not before its morning opening, on a renovation day or in a sale's hours. open: false shuts it. "flower", the flower shop | when, open, own_goods, goods, price_percent, name, lines | 1 to 6 | greeting, stock | Six spots on the benches, one kind. | open: true opens it when the clock has it shut (2 AM to 7 AM), but not while its keeper is out on her Sunday round. open: false shuts it, with its name on the door sign. "redd", Crazy Redd's tent | when, own_goods, goods, price_percent | 1 to 6 | none | Three furniture spots, set out each time the tent is entered while he is in town. | No open: it keeps its own hours. "saharah", Saharah | when, own_goods, goods, price_percent | 1 to 6 | none | One carpet, the one she offers for yours when the player talks to her. price_percent is her fee. | No open: it keeps its own hours. "fireworks", the fireworks stall | when, own_goods, goods, price_percent | 1 to 6 | none | Its goods for the night: fans, pinwheels and balloons, set out when the stall is set up. | No open: it keeps its own hours. "able", Able Sisters | when, services | none | design | No goods. Mabel sells one service, a design. | No open: it keeps its own hours. "barber", the barber shop | when, open, services | none | haircut | No goods. Monique sells one service, a haircut. | open: true opens it when the clock has it shut (2 AM to 7 AM). open: false shuts it. "dream", the Dream Suite | when, services | none | dream | No goods. Katrina sells one service, a dream visit. The suite keeps no hours, so it has no open. | No open: it keeps its own hours. "katrina", Katrina's tent | when, services | none | fortune | No goods. Katrina sells one service, a fortune, on the nights she visits. | No open: it keeps its own hours. ## Examples ## The flower shop as a tea stall From 6 PM to 4 AM the flower shop is a tea stall: its own name, its own words, and only fruit. open keeps it open after its own 2 AM closing. Outside those hours it is the game's flower shop. shops.json: ```json { "shops": { "flower": { "when": { "hours": { "from": "18:00", "to": "04:00" } }, "open": true, "own_goods": false, "goods": [ { "item": "0x2800", "price": 600 }, { "item": "0x2801", "price": 600 }, { "item": "0x2807", "price": 800 } ], "name": "Tea Stall", "lines": { "greeting": ["Welcome to the tea stall!", "Tea's hot. The fruit is fresh."], "stock": "Fruit for your tea, picked this morning." } } } } ``` The greeting is a list, so the keeper says one of the two each time you walk in. ## Goods of your own at Nook's This block has no when, so it applies every day, and it keeps Nook's own goods: shops.json: ```json { "shops": { "nook": { "goods": [ { "item": "0x1110", "price": 1800 }, { "item": "0x1108", "price": 2400 }, { "item": "0x1330" }, { "item": "0x2205", "price": 900 }, { "item": "0x2206", "price": 900 }, { "item": "0x2410", "price": 700 }, { "item": "0x2605", "price": 1500 } ] } } } ``` - That adds seven goods: three pieces of furniture, two umbrellas, a shirt and a carpet. Each stands where Nook's own goods of its kind stand. Fruit and the signboard have no spot. - There is one umbrella spot, so the date picks which umbrella shows. A good with no price sells at the usual price. - A good can be one of your own mod items by its full id, like your.mod:ghost-lantern. It stands in a furniture spot and keeps its name when bought. - This block has no when, so its goods show from the next restock: the first time the town is played on a day at or after 6:00 AM. A mod installed at noon shows the next morning. See when a change shows. ## After Hours: gyroids at night Nook's opens from 1 AM to 3 AM and sells only gyroids. open opens the shut store, and "own_goods": false leaves every spot of a kind you do not list bare: shops.json: ```json { "shops": { "nook": { "when": { "hours": { "from": "01:00", "to": "03:00" } }, "open": true, "own_goods": false, "goods": [ { "item": "0x1768" }, { "item": "0x1738" }, { "item": "0x16E4" }, { "item": "0x1780" }, { "item": "0x15BC" }, { "item": "0x15E0" } ] } } } ``` - With more goods of a kind than spots, the date and the town pick which show, so a different few stand each night. - The store does not open in the hour before its morning opening, on a renovation day or in a sale's hours. - A block with when applies at once, inside its hours, with no restock. It never touches the day's own stock. When the hours end, the day's goods are back as they were, sold ones included. With own_goods left at true, a good of the day's own bought inside your hours stays sold. - Your goods bought inside the hours are sold out until the game restarts. A restart sets them out again. - On the game's event days the event stays: grab bags stand beside the gyroids, and when the shelves are a raffle day's, the raffle takes the shop. See event days. The After Hours example in the cookbook is this shop, with its own Ghost Lantern among the gyroids now and then. ## Several blocks on one shop A list of blocks changes one shop in several ways at once. Here the flower shop always adds a sapling. On a rainy day it adds tulip seeds and says so. On winter evenings its own goods are 20 percent off. shops.json: ```json { "shops": { "flower": [ { "goods": [{ "item": "0x2900", "price": 500 }] }, { "when": { "weather": "rain" }, "goods": [{ "item": "0x2908", "price": 300 }], "lines": { "greeting": "Rainy day! The tulip seeds love it." } }, { "when": { "season": "winter", "time": "evening" }, "price_percent": 80 } ] } } ``` ## Able Sisters: the price of a design At the weekend a design costs 200 Bells at Able Sisters: shops.json: ```json { "shops": { "able": { "when": { "weekday": ["saturday", "sunday"] }, "services": { "design": 200 } } } } ``` ## Crazy Redd Redd adds a kadomatsu at a price of your own, and asks half again his own price for everything else: shops.json: ```json { "shops": { "redd": { "goods": [ { "item": "0x1108", "price": 9800 }, { "item": "0x1330" } ], "price_percent": 150 } } } ``` ## Saharah Saharah offers one of your carpets for yours, and price_percent halves her fee. With "own_goods": false she offers only your carpets. shops.json: ```json { "shops": { "saharah": { "own_goods": false, "goods": [{ "item": "0x2606" }, { "item": "0x2607" }], "price_percent": 50 } } } ``` ## The Pampered Paw's hours Monique's salon, the Pampered Paw (its shop key is barber, its new look the haircut service) is shut on Mondays. From 2 AM to 4 AM it is open for a late new look, Mondays too: when both blocks apply, the last one decides open. shops.json: ```json { "shops": { "barber": [ { "when": { "weekday": ["monday"] }, "open": false }, { "when": { "hours": { "from": "02:00", "to": "04:00" } }, "open": true, "services": { "haircut": 3000 } } ] } } ``` ## Several blocks and several mods - Inside one mod, every block of a shop whose when holds applies, together. - Their goods are sold together. A good in two of them takes the later block's price. - For a single value, open, own_goods, a percent, a service's price or a line slot, the last applying block that sets it counts. - The name is the last applying block's, or else the name of the last block that has one. ## From a script A script can change a shop for the rest of the game day. cmd.set_shop_goods(shop, goods) sets its goods and cmd.set_shop_open(shop, true) opens it (false shuts it). Each adds one more block after your shops.json blocks for that shop, from the next frame until the day changes or the game restarts. So set it again in day_started. nil clears it. - They need the permissions set_shop_goods and set_shop_open, and a World mod. - set_shop_goods takes a list of { item, price }, or { goods = , own_goods = false } to make them the whole stock. - They are refused when the shop is not in the table, does not have goods or open, or a mod later in the load order changes it. - The cookbook has a Saturday market recipe. ## Nook's spots by store size These are the spots Nook fills each morning on an ordinary day, by kind. Your goods keeping his own take up to the number in brackets. With "own_goods": false they take them all, and the kinds you do not list stay bare. Kind | Nook's Cranny | Nook 'n' Go | Nookway | Nookington's Furniture | 1 (1) | 2 (1) | 3 (2) | 5 (3) Stationery (diaries too) | 1 (1) | 2 (1) | 3 (2) | 5 (3) Clothing | 1 (1) | 2 (1) | 3 (2) | 5 (3) Carpets | 1 (1) | 1 (1) | 2 (1) | 3 (2) Wallpaper | 1 (1) | 1 (1) | 2 (1) | 3 (2) Tools | up to 2 (1) | 3 (2) | 2 (1) | 3 (2) Umbrellas | 1 (1) | 1 (1) | 1 (1) | 1 (1) Paint | none | none | 1 (1) | 1 (1) Saplings | 1 (1) | 1 (1) | 2 (1) | 3 (2) Flower bags | 2 (1) | 3 (2) | 4 (2) | 5 (3) - Nook's Cranny sells fewer tools until the town has spent enough there. - The rare furniture piece that Nookway and Nookington's show has its own spot. A mod never takes it. With "own_goods": false it stays bare, and so do the plants. - Some days have fewer spots. A grab bag sale has no stationery, tools, saplings or flower bags. The raffle has no goods. Halloween has candy instead of most flower bags, and no saplings. ## Event days at Nook's A mod never changes what kind of day it is at Nook's. The game's events stay, inside your hours too: - The grab bag sale (the day after the fourth Thursday of November): the grab bags fill the spots of the kinds the day has none of. Your goods take the spots the day has, so stationery, tools, saplings and flower bags of yours do not show that day. - Halloween (October 16 to 30): the candy fills the flower spots. - The raffle (the last day of each month): the raffle takes the whole shop, also with "own_goods": false. Your goods show again the next day. - With "own_goods": false your goods are still the whole stock on those days, with the grab bags or the candy beside them. - The kind of day follows the shelves, not the clock. A shop your mod opens after midnight still has the day before's shelves, and is the day before's kind of day, until Nook restocks at 6 AM. - The flower shop has six spots, all of one kind, so your goods keeping its own take up to three of them. ## Items you can stock - Money, turnips, tickets, grab bags and fossils are refused in every shop. - At the flower shop, an item must be one a shop table can show, so special items cannot be stocked there either. - The game's own furniture cannot be stocked at the flower shop, because no piece of it has a shop table model. To sell the game's furniture, stock Nook's instead. - Your own mod items can be stocked at Nook's and the flower shop only. - The game leaves out an item it cannot sell. Your mod's row in the Mods tab names the item and the reason, for example "has no shop shelf model". The rest of the shop still loads. The flower shop sells these items itself, so they always work there: Item | Number Apple | "0x2800" Cherry | "0x2801" Pear | "0x2802" Peach | "0x2803" Orange | "0x2804" Coconut | "0x2807" Sapling | "0x2900" Cedar sapling | "0x2901" White pansy seeds | "0x2902" Purple pansy seeds | "0x2903" Yellow pansy seeds | "0x2904" White cosmos seeds | "0x2905" Pink cosmos seeds | "0x2906" Blue cosmos seeds | "0x2907" Red tulip seeds | "0x2908" White tulip seeds | "0x2909" Yellow tulip seeds | "0x290A" The item list has every other item. It gives each item's name and usual price, and says whether the flower shop or Nook's can stock it. The flower shop can stock 831 goods and Nook's 1996. Filter the list by name. playac-mod check warns about a good the game would leave out and about a price under the floor. ## Prices - Leave a good's price out and it sells at the shop's own price, or at price_percent of it while a block with one applies. - Each good has a floor: the lowest price it can sell for. The floor is what Nook pays for the good, a quarter of its usual price. The game raises a lower price, or a lower price_percent, to the floor, so a shop can never be used to make free Bells. items.json gives each good's floor at Nook's and the flower shop. - The town fruits are apple, cherry, pear, peach and orange. Their floor is what Nook pays for fruit from another town, 500 Bells. This holds even for your town's own fruit, which Nook buys for 100. - A coconut is not a town fruit. Its floor is its own buy-back price, 150 Bells. - At Nook's, price is what he asks for the good on the shop floor. Catalog orders stay at the usual price. - buy_back_percent never makes Nook pay more for an item than he asks for it at that moment. ## Two shop mods Each shop is decided on its own. If two switched-on mods both change the same shop, the mod lower in the Mods tab list has the whole of that shop. Nothing of the other mod's blocks for it is mixed in. One mod can have the flower shop while another has Nook's. - A shop's lines are written for its own goods, so the winner has all its blocks for that shop. The two mods' goods are not added together, even when both keep the shop's own. - The other mod's row in the Mods tab says its change to that shop is not used and names the mod that has it. - A script's villager_talked line goes the other way: the first mod in the list that returns one speaks. See load order. ## Visitors and The City - Friends who visit your town see your shops. - A mod with a shop always counts for visits. The rule is in Multiplayer. - In The City, a World mod's shops switch off. The City's shops are always the game's own. The After Hours recipe is a working shop to copy. It changes Nook's, and the same block works on any shop: change the id, and keep to the fields and goods that shop has. --- ## Page: https://playaconline.com/modding/guides/textures/ ## Texture mods A texture mod swaps a picture the game draws for one you painted. You need a mod folder to put pictures in. Download the texture kit and unzip it. Put your name in its mod.json. ## Three steps - Save the pictures. In the model viewer, open the model, press Textures, then Save all. You get a ZIP named for the model, like spooky-wardrobe-textures.zip, with every texture of the model, each already named with a label in front. Unzip it. The pictures come from the game data loaded in your browser, read from your own disc. Nothing is downloaded from our servers. - Paint over the pictures. Use any paint program that saves PNG. Keep each file's name. Delete the ones you did not paint. - Drop them into the mod's textures/ folder and watch them change live. Run playac-mod dev in the mod folder and connect the game to it (developer mode). After one restart, the game draws each picture again every time you save it. Paint every pixel yourself. The saved pictures are the game's art: use them for the layout only. A recolour or a trace is still the game's picture. It is fine in your own game, never in a shared mod (rules). No playac-mod? In developer mode, Choose folder works too, live in Chrome and Edge. To install for good, ZIP the folder and install it from Settings, Mods. The artist path shows every click. ## Reference You need none of this for the three steps. ## The model viewer - It lists models: villagers, furniture, clothing, tools, trees and rocks, buildings and more. It also lists what is not a model. Ground and water has the town's acres. Rooms and sky has room floors and walls, and the train window. Menus and UI, Effects and More textures have the rest. - Pick one texture in the panel for its own buttons. Copy name copies its exact name. Any palette copies its $ name. Save PNG saves that one picture. - Some textures load only while the model moves, such as a villager's eyes and mouth. Let the model play and the list grows. ## File names the pattern: ```