Events
What a script can listen to, and what each handler receives.
List every event your script handles in mod.json. Then register a handler for each one while the script loads:
"scripts": { "main": "main.lua", "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", "player_acted"] }on("villager_talked", function(e)
return { place = "before", line = "Hi " .. e.villager.name .. "!" }
end)Every handler gets exactly one table, e. A field with nothing to say is nil, never an empty
string or 0. The table is a copy, so changing it changes nothing in the game.
Ids are always numbers in Lua. JSON files write them as "0x2800" strings. A cmd.* call takes
a number, "0x2800" or your mod's own "author.mod:thing".
villageris the same table wherever a villager appears. Its fields areid,name,speciesandpersonality. Every villager is on the villagers list.itemis the item number.mod_itemis the full id of a mod item when the piece is one, anditemis then its base piece. Otherwisemod_itemisnil.scenenumbers and names are on the scenes list.
Index #
| Event | When |
|---|---|
villager_talked | The player starts an ordinary talk with a villager. |
day_started | A new day begins in the game. |
item_picked_up | The player got an item. |
scene_entered | A scene starts, such as the town, a house or a shop. |
data_migrated | Fires once per town, when mod.json "data_version" differs from the version the town's data was written at. |
hour_changed | The game's clock reached a new hour. |
item_bought | The player bought a good for Bells at any counter in the game. |
item_sold | The player sold for Bells. |
fish_caught | A fish was landed. |
bug_caught | A bug was netted. |
letter_read | The player chose Read on a letter. |
villager_moved_in | A villager with no house was given one. |
visitor_arrived | A friend is riding into this player's own town. |
command_finished | A command this mod queued was applied or refused. |
question_answered | The player answered this mod's ask, or closed it. |
timer_fired | A timer this mod set with timer.after is due. |
villager_answered | The player answered the question this mod's conversation asked (villager_talked returned place = "conversation" with an ask). |
button_pressed | A button on the player's controller was pressed. |
button_released | A button on the player's controller was let go. |
player_acted | The player started one of the actions below. |
Events #
villager_talkedsince 1 #
handler(e: table) -> 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.villager | table | The villager. It is a copy, so changing it changes nothing. |
e.villager.id | integer | The villager's id (villagers.json). |
e.villager.name | string | The villager's name. |
e.villager.species | string|nil | cat, dog and so on (villagers.json). nil when the game cannot tell. |
e.villager.personality | string|nil | normal, peppy, lazy, jock, cranky or snooty. nil when the game cannot tell. |
Returns table|nil: nil, a talk table { place, line, topics, ask }, or a list of talk tables.
day_startedsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.year | integer | |
e.month | integer | 1 to 12. |
e.day | integer | 1 to 31. |
e.weekday | integer | 0 (Sunday) to 6, as game.time(). |
item_picked_upsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.item | integer | The item number (items.json). For a mod item, it is the base piece the item stands on. |
e.mod_item | string|nil | The full id ("author.mod:thing") when the pocket slot it landed in holds a mod item. That is a mod item picked up in the player's own house, the one place a mod item stands. nil for a plain item, on a visit and in The City. |
scene_enteredsince 1 #
handler(e: table) 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).
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.scene | integer | The scene number (scenes.json). |
e.name | string|nil | The scene's name from scenes.json, like "town". nil for a scene with no published name. |
data_migratedsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.from | integer | The version the town's data was written at. 0 for data from before data_version. |
e.to | integer | mod.json data_version now. |
hour_changedsince 1 #
handler(e: table) The game's clock reached a new hour. This is the game's own hourly update, midnight included.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.year | integer | |
e.month | integer | |
e.day | integer | |
e.hour | integer | 0 to 23. |
item_boughtsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.item | integer | The item number (items.json). For a mod item, it is the base piece the item stands on. |
e.mod_item | string|nil | The full id ("author.mod:thing") when the piece is a mod item, else nil. |
e.price | integer | The Bells paid. |
e.shop | string | Which counter. |
e.ordered | boolean | true for a catalog order, mailed tomorrow. |
item_soldsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.item | integer | The item number (items.json). For a mod item, it is the base piece the item stands on. |
e.mod_item | string|nil | The full id ("author.mod:thing") when the piece is a mod item, else nil. |
e.count | integer | How many goods went. |
e.bells | integer | What they fetched. |
e.shop | string | Who bought. |
fish_caughtsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.item | integer | The fish's item number (items.json). A fish is never a mod item, so this event has no mod_item. |
e.pocketed | boolean |
bug_caughtsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.item | integer | The bug's item number (items.json). A bug is never a mod item, so this event has no mod_item. |
e.pocketed | boolean |
letter_readsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.sender | string|nil | The name the letter is from, as game.player().name spells a name. nil when the letter carries no sender name. |
e.item | integer|nil | The present's item number. nil when the letter carries none. |
e.mod_item | string|nil | The present's full id ("author.mod:thing") when it is a mod item, else nil. A letter keeps its mod item present while it moves between the pockets, the mailbox and the post office. nil on a visit and in The City. |
e.first_time | boolean | true the first time this letter is read. |
e.letter | string|nil | The letter's full id ("<mod id>:<letter id>") when it is a letter from an enabled mod's letters file, sent by cmd.send_letter{ template } or a calendar day. Nothing is written into the save for it. The game finds it by what the saved letter holds: its words (body and footer), the sender name in the mailbox list and the paper, and only among letters the game itself mailed. So it still answers after a save and a reload, and a letter a player wrote by hand with the same words is never named. nil for the game's letters, a player's letters and a cmd.send_letter{ text } letter. Two mod letters with the same words, sender and paper are told apart by nothing, and the first in load order is named. A letter mailed before its mod changed its words, sender or paper is no longer named. |
villager_moved_insince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.villager | table | The villager who moved in. |
e.villager.id | integer | The villager's id (villagers.json). |
e.villager.name | string | The villager's name. |
e.villager.species | string|nil | cat, dog and so on (villagers.json). nil when the game cannot tell. |
e.villager.personality | string|nil | normal, peppy, lazy, jock, cranky or snooty. nil when the game cannot tell. |
visitor_arrivedsince 1 #
handler(e: table) A friend is riding into this player's own town. This is a friend visit, on the host's side. kind is "friend".
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.kind | string | "friend". |
command_finishedsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.id | integer | The id the cmd.* call returned. |
e.command | string | send_letter, give_item, show_line, ask, take_item, take_bells, save, set_weather or play_sound. |
e.ok | boolean | |
e.via | string|nil | How it was applied: mailbox, post_office, pockets, mail, shown, taken, saved, set, unchanged or played. nil when refused. |
e.code | CommandCode|nil | The refusal's stable code (command_codes). nil when applied. |
e.message | string|nil | Why it was refused, in words. nil when applied. |
question_answeredsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.id | integer | The id cmd.ask returned. |
e.choice | integer|nil | Which answer, counting from 1. nil with no pick. |
e.text | string|nil | The answer's text. nil with no pick. |
timer_firedsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.id | integer | The id timer.after returned. |
e.name | string | The name given to timer.after. |
e.data | string|number|boolean|nil | The data given to timer.after. nil when none was given. |
villager_answeredsince 1 #
handler(e: table) -> 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.villager | table | The villager. It is a copy, so changing it changes nothing. |
e.villager.id | integer | The villager's id (villagers.json). |
e.villager.name | string | The villager's name. |
e.villager.species | string|nil | cat, dog and so on (villagers.json). nil when the game cannot tell. |
e.villager.personality | string|nil | normal, peppy, lazy, jock, cranky or snooty. nil when the game cannot tell. |
e.choice | integer | Which answer, counting from 1. |
e.text | string | The answer's text. |
Returns string|table|nil: nil, a line, or a reply table { line, ask }.
button_pressedsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.button | string | One of 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. |
button_releasedsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.button | string | One of 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. |
player_actedsince 1 #
handler(e: table) 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.
| Parameter | Type | Description |
|---|---|---|
e | table | |
e.action | string | One of: axe_swung (at a tree or at nothing), axe_hit_rock (the axe bounced off a rock or something hard), axe_broke, net_swung, rod_cast, shovel_dug (a hole), hole_filled, tree_shaken, sat_down, stood_up (from a seat or out of bed), lay_down (on a bed), stung (by a bee or a mosquito), fell_in_pitfall, tripped, shocked (the game startles the player, such as at a cockroach), door_entered, reacted (a reaction: from the reactions bar or cmd.react). The list may grow: ignore a word you do not know. |
e.item | integer|nil | The tool's item number (items.json) for an axe, net, rod or shovel action, as the game holds it at that moment: an axe's number changes as it wears. nil for every other action. |
e.reaction | string|nil | For reacted, which reaction: one of cmd.react's names. nil for every other action. |
Commands #
send_letter(t: table) -> integer|nil: 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.give_item(item: integer|string|table) -> integer|nil: 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.show_line(text: string) -> integer|nil: 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.ask(t: table) -> integer|nil: Queues a question with 2 to 4 answers in that same speakerless message box. The pick comes back as a question_answered event.take_item(t: table) -> integer|nil: 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.take_bells(t: table) -> integer|nil: 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.save() -> integer|nil: 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.set_weather(kind: string, intensity: string|nil) -> integer|nil: 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.play_sound(name: string) -> integer|nil: 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.set_shop_goods(shop: string, goods: table|nil) -> boolean|nil: 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.set_shop_open(shop: string, open: boolean|nil) -> boolean|nil: 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.set_hat(picture: string|nil) -> boolean|nil: 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.set_shirt(picture: string|nil) -> boolean|nil: 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.react(name: string) -> boolean|nil: 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.
A refused command gives a code that says whether to try again. The codes are on the commands guide.