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.

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...WhereAPI
Change how the town looks (textures)Springtime Town, mod.json line 13mod.json content
Start a texture mod with the file names readyTexture kit, mod.json line 11mod.json content
Give villagers new lines, by personalitySpringtime Town, talk.json line 5talk.json personality
Give one villager lines of their ownVillager lines kit, talk.json line 58talk.json villager,talk.json chance
Give villagers lines for the weather, the season or the time of daySmall talk for the weather, the season and the time of daytalk.json season,talk.json time,talk.json weather
Put lines before the hello, as the hello, after the topic or as the whole talkLines anywhere in a talk: before, hello, topic, after, the whole conversationtalk.json place,talk.json topics,talk.json day
Have a villager ask the player a questionA villager asks the player somethingvillager_talked,villager_answered
Change the flower shop: name, hours, lines and goodsShop kit, shops.json line 3shops.json when,shops.json hours,shops.json own_goods,shops.json goods,shops.json name,shops.json lines
Add goods to Nook'sShop kit, shops.json line 18shops.json goods,shops.json price
Open Nook's at hours of your own, with only your goodsAfter Hours, shops.json line 3shops.json when,shops.json hours,shops.json open,shops.json own_goods
Change a shop's goods or open it from a scriptA Saturday fruit market at the flower shopcmd.set_shop_goods,cmd.set_shop_open
Put a picture of your own on the player's hatButton Tricks, main.lua line 18cmd.set_hat,scene_entered,store.player
Count what the player does, and cheer on a milestoneButton Tricks, main.lua line 114player_acted,cmd.react,game.player,timer.after
Put a picture of your own on the player's shirtButton Tricks, main.lua line 19cmd.set_shirt,scene_entered,store.player
Add a new item with its own picturesAfter Hours, items.json line 3mod.json content,items.json base,items.json textures
Sell your own item in a shopAfter Hours, shops.json line 8shops.json item
Rename an item players already haveRename a mod item players already havemod.json renames
Add a calendar day with a bulletin board noticeHarvest Post, calendar.json line 6calendar.json date,calendar.json board
Give a calendar day villager linesHarvest Post, talk.json line 5talk.json day,talk.json place
Mail a letter on a calendar day, with no scriptHarvest Post, calendar.json line 12calendar.json letter
Write a letter templateHarvest Post, letters.json line 4letters.json header,letters.json body,letters.json footer,letters.json sender
Run code when a new day startsScript kit, main.lua line 38day_started
Run code when the player enters a sceneScript kit, main.lua line 134scene_entered
Have a villager say a line that depends on the gameScript kit, main.lua line 101villager_talked,game.pockets,game.day_number,message
React to an item picked upScript kit, main.lua line 56item_picked_up
React to a fish caught (a bug works the same way)Script kit, main.lua line 65fish_caught,bug_caught
Do something at a set hourHarvest Post, main.lua line 164hour_changed
Know whether today is one of your calendar daysHarvest Post, main.lua line 33game.calendar_today
React to the player reading a letterHarvest Post, main.lua line 235letter_read
React to buying or sellingA thank-you letter after spending Bells at Nook'sitem_bought,item_sold
Notice a new villager, or a friend riding inNotice a new villager, or a friend riding invillager_moved_in,visitor_arrived
Show the player a lineScript kit, main.lua line 71cmd.show_line
Give the player an itemScript kit, main.lua line 123cmd.give_item
Know whether a command workedScript kit, main.lua line 142command_finished
Mail a letter from a scriptHarvest Post, main.lua line 75cmd.send_letter
Mail a letter template from a scriptHarvest Post, main.lua line 189cmd.send_letter
Ask the player a questionHarvest Post, main.lua line 131cmd.ask
Read the answer to a questionHarvest Post, main.lua line 142question_answered
Take Bells from the playerHarvest Post, main.lua line 152cmd.take_bells
Take an item from the playerSwap an item for anothercmd.take_item
React to a button or a hotkeyA hotkey: a button combinationbutton_pressed,button_released,game.input
Save the gameSave the game each time the player steps outsidecmd.save
Play one of the game's soundsPlay a jingle when a fish is caughtcmd.play_sound
Change the weatherA rainy morning that clears by nooncmd.set_weather
Save data for the townHarvest Post, main.lua line 101store.get,store.set
Save data for each playerHarvest Post, main.lua line 77store.player.get,store.player.set
Save data for this browser, whatever the townRemember something in this browser, whatever the townstore.client.get,store.client.set,store.town
Change the shape of saved dataChange the shape of saved datamod.json data_version,data_migrated
Pick something at randomHarvest Post, main.lua line 68rng
Run code later (a timer)Harvest Post, main.lua line 99timer.after,timer_fired
Cancel a timerHarvest Post, main.lua line 114timer.cancel
Read the town, the player and the clockHarvest Post, main.lua line 28game.town,game.player
Read the weather and where the player isA weather report on the hour: where you are and what is fallinggame.weather,game.place
Add a setting the player can change (choice, World)Harvest Post, mod.json line 39mod.json settings,settings.get
Add an on or off setting to a Just you modScript kit, mod.json line 20mod.json settings,settings.get
Add a setting only its own player sees (client scope)A setting only its own player seesmod.json settings
Offer a function to other modsHarvest Post, main.lua line 53remote.add,mod.json exports
Use another mod when it is thereScript kit, main.lua line 23mod.json optional_depends,remote.version,remote.has,remote.call
Need another mod, refuse one, or read its linesNeed another mod, or refuse to run with onemod.json depends,mod.json conflicts,remote.call,message

Recipes #

There are 4 example mods. Each shows two kinds of mod working together in one mod.

ModKindRepository
Springtime TownTextures and villager lines, no codeplayac-example-springtime-town
After HoursNook's at night, an item with its own picturesplayac-example-after-hours
Harvest PostCalendar days, letters, a script with commands and a timerplayac-example-harvest-post
Button TricksButtons, looks, weather, reactions and savesplayac-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: Textures, Villager talk pools, Just you mod. 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
Before: a corner of town on a September afternoon, with no mods and the HD texture pack.
Before: a corner of town on a September afternoon, with no mods and the HD texture pack.
After: the same spot with Springtime Town installed. The grass is the mod's, drawn with clover and tiny white flowers; the trees, houses and paths are untouched.
After: the same spot with Springtime Town installed. The grass is the mod's, drawn with clover and tiny white flowers; the trees, houses and paths are untouched.
Twiggy's own hello, then the menu after it. Choose "I'm bored!" to chat, and she picks a topic.
Twiggy's own hello, then the menu after it. Choose "I'm bored!" to chat, and she picks a topic.
This time the topic is small talk, and her small talk is a line from the mod's peppy pool.
This time the topic is small talk, and her small talk is a line from the mod's peppy pool.
Video: A walk past the houses on the mod's clover grass, then a chat with Twiggy: her hello, "I'm bored!", and a line from the mod as her small talk.

A Just you mod ("scope": "client") in two halves, with no script:

- **The grass** (textures/): the town grass is our own drawing, seamless green ground with clover leaves and small white flowers. - **The talk** (talk.json): new small talk in each villager's own personality's voice, some of it for the season, the time of day or the weather, and an evening goodbye after the topic.

Both are data. Neither changes what a visitor sees, so the mod is Just you.

The grass #

The grass is one 128x128 uncompressed RGBA DDS picture, saved under every name the game draws the grass with. The names say which in-game texture to replace, and the pixels are our own.

The grass is six textures. The game draws each under several palettes, through the seasons and the time of day. A file can name one texture and one palette:

from the README
tex1_32x32_<texture>_<palette>_8.dds

Or it can put $ in place of the palette, for that texture under any palette:

from the README
tex1_32x32_<texture>_$_8.dds

Our grass is the same picture all year, so the mod has one $ file per texture. That is six files.

These three grass textures are drawn under nine palettes:

from the README
textures: 626709d910129694 903adc6355e36f59 e96fecd242518c9f
palettes: 193ca5974976e36e 20430b0042498b04 4f54e78515f0a185
          8910d24f6fbd5f83 8b8a1c2cacd60254 963dc45f18e13cf7
          b2e512f9c0fe88ad e7f9e59c09c5f9d0 f83e63a8b6cb47b7

And these three under three palettes:

from the README
textures: 82f28ec4199a45be cfa57a6e6f966d11 e2ab673814e71af6
palettes: 6d5ff5628ae85b42 ce63d23d746a058a d9eb32f9a8b17411

To change the grass for one stretch of the year or one time of day, add a file named with that palette next to the $ file. The file named for one palette wins under that palette, and the $ file still covers the rest.

With one file per palette, 36 files, the mod could change with every palette. A $ file is loaded once and shared, so it is the lighter choice when the picture does not change.

The pictures were drawn by a small program, never copied from the game.

The talk #

Talk to a villager and choose to chat. After their hello they pick a topic, the way they always do: a trade, a letter, a hint, or small talk. When they pick small talk, the line can come from this mod.

talk.json holds line pools. Each personality has its own pool, and a few more pools are kept to a moment: a normal villager has a line for spring, a peppy one for the rain, a lazy one for the evening, a jock for winter, a cranky one for the snow and a snooty one for a spring morning ("season", "time" and "weather"). A pool counts only at its moment, and among the pools that count the game picks one line. A villager can say several of the mod's lines in a day, and never the same one twice running.

A pool can instead name one villager ("villager": "Bob"), or nobody, which means every villager, and can be said less often ("chance": 30; every time it fits when left out). The most specific pools that fit a villager decide.

Every pool names its place in the talk. The small talk pools say "place": "topic": their lines stand in for the topic the villager picks when you chat. The last pool says "place": "after": on an evening chat, half the time, any villager adds a line after their topic, as the talk's last message. Its line is a list of two pages, each on a clean window. A pool's place can also be "before" the hello, the "hello" itself or the whole "conversation".

No script is needed.

Make your own #

This repository is one mod, laid out the way the GitHub import wants it: mod.json at the top, and a tag named for the version in mod.json.

1. Copy the repository to your own account. 2. Change "id" in mod.json to your own, like yourname.springtime-town. Ids that start with example. are kept for these examples, so the import refuses them. 3. Tag the commit with the version, like v1.0.0. 4. Push the commit and the tag. Then, in the game, open **Settings**, then **Mods**, and scroll to **Share a mod**. Sign in, answer the age question and accept the mod rules the first time, and type the code from your authenticator app. **Import from GitHub** shows under the upload form once the code is accepted. Paste github.com/<you>/<repository>@v1.0.0 there and choose **Import**.

To keep only one half, delete the other half's files and its lines in mod.json, and playac-mod check tells you if anything still points at them.

The modding guide is at playaconline.com/modding.

media/ holds the pictures and the film the cookbook shows, with their captions in media/media.json. .playac/screenshots/ holds the listing's screenshots.

What goes in the mod's ZIP is decided by the pack rule, the same for playac-mod pack and the GitHub import:

- Left out: this repository's own files. Those are this README.md, CHANGELOG.md (it is sent beside the ZIP as the listing's changelog), LICENSE, the whole media/ folder with its pictures, film and media.json, and the screenshots (.playac starts with a dot). The game ignores the same files in any ZIP. - Kept: every other .json, .lua, .dds, .png, .txt and .md file.

Download Springtime Town as a ZIP, ready to install. It downloads from the example's release on GitHub.

Its 6 pictures are not text, so they are listed here by name. Each links to the file in the repository.

{
  "schema": 1,
  "api": 1,
  "id": "example.springtime-town",
  "name": "Springtime Town",
  "version": "1.0.0",
  "authors": [
    "Play AC Online"
  ],
  "description": "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.",
  "scope": "client",
  "content": {
    "textures": "textures/",
    "talk": "talk.json"
  },
  "assets_original": true
}

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: A shop, New items, World mod. 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
1:20 AM in the rain: the town shop is lit and open, hours after it would usually shut.
1:20 AM in the rain: the town shop is lit and open, hours after it would usually shut.
Inside at night every shelf is bare. The only goods are by the counter: tonight a Ghost Lantern and a gyroid.
Inside at night every shelf is bare. The only goods are by the counter: tonight a Ghost Lantern and a gyroid.
The Ghost Lantern, the mod's own piece: a tall lantern with green glowing windows, a face in them, and moss down its stone. Only this lantern wears these pictures.
The Ghost Lantern, the mod's own piece: a tall lantern with green glowing windows, a face in them, and moss down its stone. Only this lantern wears these pictures.
The same shop at 10 AM: the day's own goods on every shelf. The mod changes nothing outside its hours.
The same shop at 10 AM: the day's own goods on every shelf. The mod changes nothing outside its hours.
Video: Inside the shop at 1:20 AM with the mod: empty shelves, and by the counter only tonight's gyroid and the Ghost Lantern.

A World mod ("scope": "world") in two halves:

- **The shop** (shops.json): from 1 AM to 3 AM the town shop opens again, and all it sells is gyroids, a different few each night. Every other spot is empty. - **The lantern** (items.json, items/ghost-lantern/): the Ghost Lantern, a tall lantern of the mod's own with its own pictures. Now and then it stands among the gyroids.

A shop changes the town, so the mod is a World mod.

The shop #

shops.json changes one shop, Nook's store, by its id "nook". Its block says when it applies, what it does then, and its sixteen goods: fifteen gyroids and the Ghost Lantern.

- "when": { "hours": { "from": "01:00", "to": "03:00" } }: the block applies only inside these hours. - "open": true: while it applies the shop is open, even though it is shut at night. - "own_goods": false: while it applies the mod's goods are the shop's whole stock. Each furniture spot holds one of them and every other spot is bare. Without it the goods would join the day's own instead. - Outside the hours nothing changes. The shop keeps its own hours and its own goods, and the day's stock is still there when it opens in the morning. - The shop has fewer furniture spots than sixteen goods, so it shows a few of them each night, and a different few the next night. The Ghost Lantern is one of the sixteen, so it is there only on some nights. - A good may be an item of the same mod, named by its full id, example.after-hours:ghost-lantern. Without a price it takes the item's own price from items.json. The gyroids sell at the game's own price. - Every shop takes the same fields with the same meaning. The same block works on the flower shop as "flower".

The lantern #

items.json lists the new item. It has an id, a name, a price, a base (the game's own piece it is built on, here the tall lantern) and textures, a folder of pictures only this item draws.

- The pictures in items/ghost-lantern/ are named like texture mod files, after the base's textures. Only the Ghost Lantern wears them: a tall lantern next to it keeps its own look. Four of the lantern's textures are replaced, the windows and the stone beside them, and the rest stay the base's. - A gyroid cannot be a base, so the mod's own piece is a lantern. - With the mod installed, the piece is the mod's item, with its own name. - Remove the mod and the piece stays in the house as the plain base piece. - Put the mod back and it is the mod's item again.

Other files name an item as example.after-hours:ghost-lantern: the mod id, a colon, and the item id. Never change an item's id once players have it. To rename one in a later version, map the old id to the new one with "renames" in mod.json.

Make your own #

This repository is one mod, laid out the way the GitHub import wants it: mod.json at the top, and a tag named for the version in mod.json.

1. Copy the repository to your own account. 2. Change "id" in mod.json to your own, like yourname.after-hours, and the full ids in shops.json with it. Ids that start with example. are kept for these examples, so the import refuses them. 3. Tag the commit with the version, like v1.0.0. 4. Push the commit and the tag. Then, in the game, open **Settings**, then **Mods**, and scroll to **Share a mod**. Sign in, answer the age question and accept the mod rules the first time, and type the code from your authenticator app. **Import from GitHub** shows under the upload form once the code is accepted. Paste github.com/<you>/<repository>@v1.0.0 there and choose **Import**.

To keep only one half, delete the other half's files and its lines in mod.json, and playac-mod check tells you if anything still points at them.

The modding guide is at playaconline.com/modding.

media/ holds the pictures and the film the cookbook shows, with their captions in media/media.json. .playac/screenshots/ holds the listing's screenshots.

What goes in the mod's ZIP is decided by the pack rule, the same for playac-mod pack and the GitHub import:

- Left out: this repository's own files. Those are this README.md, CHANGELOG.md (it is sent beside the ZIP as the listing's changelog), LICENSE, the whole media/ folder with its pictures, film and media.json, and the screenshots (.playac starts with a dot). The game ignores the same files in any ZIP. - Kept: every other .json, .lua, .dds, .png, .txt and .md file.

Download After Hours as a ZIP, ready to install. It downloads from the example's release on GitHub.

Its 4 pictures are not text, so they are listed here by name. Each links to the file in the repository.

{
  "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
}

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: Lines, Letters, Calendar days, Villager talk pools, Lua script (day_started, scene_entered, hour_changed, question_answered, command_finished, timer_fired, letter_read), World mod. 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
On the third Wednesday of September the town bulletin board carries the mod's notice, dated by the game.
On the third Wednesday of September the town bulletin board carries the mod's notice, dated by the game.
All day, villagers open with a line about the fair from the mod's calendar.json, then carry on in their own words.
All day, villagers open with a line about the fair from the mod's calendar.json, then carry on in their own words.
The day's first visit to town: the mod's script has already mailed today's letter, so there is mail waiting at the house.
The day's first visit to town: the mod's script has already mailed today's letter, so there is mail waiting at the house.
The letter is the mod's own text, from its messages file, sent with the send_letter command from "A friend", with a little present attached.
The letter is the mod's own text, from its messages file, sent with the send_letter command from "A friend", with a little present attached.
Video: The Harvest Fair notice on the bulletin board and Twiggy talking about the fair before her usual chat, then a walk to the mailbox to take out the day's letter and read it.

A World mod ("scope": "world") in two halves:

- **The calendar** (calendar.json, letters.json, talk.json): two days of our own. The Harvest Fair is the third Wednesday of September and Apple Day is October 21. A notice goes up on the bulletin board and villagers talk about it all day. - **The post** (main.lua, messages.json): once a game day, a script mails you a letter with a little present. On fair day it runs a fruit contest with a 100 Bell entry fee. A worked example of mod commands, a question, a setting, a timer and a function other mods can call.

A board notice changes the town, so the whole mod is a World mod. It still does not count for a friend visit: only a World mod with textures, shops or items does, so two friends need not both have it. The board notice goes up in the player's own town only. The script half alone would run in a Just you mod too.

The calendar #

- It adds two calendar days. The Harvest Fair is the third Wednesday of September (week 3, weekday 3). Apple Day is October 21 (day). - On each day a notice goes up on the town bulletin board. It is posted once, in the player's own town only. - talk.json has a pool for each day: "day" names the calendar day by its id, and "place": "before" puts the line before the villager's hello. Every pool names its place; the others are the hello itself, the topic after a chat answer, a line after the topic, and the whole conversation. - letters.json holds two letter templates. The player's name goes where {player} is, and an apple comes with each. - fair-thanks is mailed by the script, with cmd.send_letter{ template = "fair-thanks" }, once a player pays to enter the fruit contest. Another mod's command would name it example.harvest-post:fair-thanks. - apple-day is mailed by the calendar, with no script: the Apple Day entry in calendar.json says "letter": "apple-day". It goes out once on the day, the first time the player is free in their own town, and it counts against the mod's 3 letters a day. - The thank-you signs "The Fair Committee". The mailbox list has room for 8 characters, so sender names it "The Fair" there.

Letter and notice text is plain ASCII and must fit six lines of the paper. The game measures it in its own font and refuses text that does not fit.

The post: commands #

An event handler never changes the game itself. It queues a command, and the game applies it at the end of a frame's update, once the player is free.

- cmd.send_letter{ text = ..., item = ..., from = ... } queues the letter. It returns the command's id, or nil, a message and a code when the game refuses it now. The text and the sender come from messages.json, read with message("letter") and message("from"). - "permissions": ["send_letter"] in mod.json names the command. A command the mod does not name is refused. - command_finished says what happened to it: e.ok, e.via (mailbox, or post_office when the mailbox was full), or e.code and e.message for a refusal. - The game's cap is 3 letters a day from one mod, per town. The refusal's code is command-day-cap.

The post: a setting #

mod.json declares one setting, present, a choice of fruit or none. The player sets it on the Mods tab, and settings.get("present") reads it. With none the daily letter comes with no present.

- A setting has no scope, so it is world, 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. - A World setting may decide what the town gets, so the letter command after it is allowed. A "scope": "client" setting is each player's own, and in a handler that read one the game refuses send_letter, give_item, take_item and take_bells with command-client-setting. The script kit shows a client setting.

The fruit contest: a question and a take #

On the Harvest Fair, the first time a resident enters the town, the script asks them to enter the fruit contest.

- cmd.ask{ text = message("contest"), choices = { "Apple", "Pear", "Not today" } } puts the question in the player's thought window. It has 2 to 4 answers of up to 16 characters. - question_answered brings back e.id (what cmd.ask returned), e.choice (counting from 1) and e.text. Both are nil when the window closed with no pick. - For Apple or Pear, cmd.take_bells{ amount = 100 } asks for the fee. The game shows its own question, which names the amount and the mod, and the player says yes or no there. The script cannot change those words. - command_finished with e.command == "take_bells" says how it went: e.via is "taken" on yes, and e.code is command-declined on no, or command-not-held when the wallet holds less than 100 Bells. - Once the fee is taken the script mails fair-thanks. - A take is refused on a visit, so the contest is asked only at home: store.town() starts with "v:" away from home.

The fair at 6 PM: hour_changed and show_line #

hour_changed fires on the game's own hourly update, with e.hour from 0 to 23. At 18 on fair day the script runs cmd.show_line(message("packing_up")), which puts a line in the player's thought window once they are free.

game.calendar_today() tells the script which of its calendar days fall today. It lists this mod's own days only, by their id in calendar.json.

A function other mods can call #

remote.add("fair_today", ...) offers a function to other mods while the script loads. "exports" in mod.json lists it, with one line that says what it returns, and the game then lets the script offer only the names listed.

Another mod names Harvest Post in "optional_depends" and calls it:

from the README
if remote.version("example.harvest-post") and remote.has("example.harvest-post", "fair_today") then
  local fair = remote.call("example.harvest-post", "fair_today")
end

The script kit in the modding guide does exactly that.

The post: timers #

A letter the game could not take now (both boxes full, or the player away from home) is tried again half a game hour later.

- timer.after(30, "retry", p.id) counts game minutes. The timer is kept with the town's data, so it still fires after a save and a reload. - timer_fired brings back the name and the data: here, whose letter it was. - timer.cancel(id) cancels a waiting timer. When the letter gets through on the next scene first, the script cancels the retry.

The post: saved data #

- store.player remembers the day's letter, so each resident of the town gets their own. - The town's store keeps the mark that a retry timer is waiting, under the resident's id. The timer may fire while another resident plays, and only the town's store can be cleared then. - rng() counts the numbers the mod drew in this town today and keeps that count with the town, so reloading the game cannot reroll the present.

The post: events #

day_started sends the day's letter. scene_entered tries too, since a game loaded on a day it already saw does not run day_started again.

command_finished comes for every command, the line and the question too (e.via is "shown" for those), so the script reads e.command first.

letter_read fires when the player reads a letter. e.letter is "example.harvest-post:fair-thanks" or "example.harvest-post:apple-day" for this mod's templates, and nil for a letter sent as plain text.

Make your own #

This repository is one mod, laid out the way the GitHub import wants it: mod.json at the top, and a tag named for the version in mod.json.

1. Copy the repository to your own account. 2. Change "id" in mod.json to your own, like yourname.harvest-post. Ids that start with example. are kept for these examples, so the import refuses them. 3. Tag the commit with the version, like v1.0.0. 4. Push the commit and the tag. Then, in the game, open **Settings**, then **Mods**, and scroll to **Share a mod**. Sign in, answer the age question and accept the mod rules the first time, and type the code from your authenticator app. **Import from GitHub** shows under the upload form once the code is accepted. Paste github.com/<you>/<repository>@v1.0.0 there and choose **Import**.

To keep only one half, delete the other half's files and its lines in mod.json, and playac-mod check tells you if anything still points at them.

The modding guide is at playaconline.com/modding.

media/ holds the pictures and the film the cookbook shows, with their captions in media/media.json. .playac/screenshots/ holds the listing's screenshots.

What goes in the mod's ZIP is decided by the pack rule, the same for playac-mod pack and the GitHub import:

- Left out: this repository's own files. Those are this README.md, CHANGELOG.md (it is sent beside the ZIP as the listing's changelog), LICENSE, the whole media/ folder with its pictures, film and media.json, and the screenshots (.playac starts with a dot). The game ignores the same files in any ZIP. - Kept: every other .json, .lua, .dds, .png, .txt and .md file.

Download Harvest Post as a ZIP, ready to install. It downloads from the example's release on GitHub.

{
  "schema": 1,
  "api": 1,
  "id": "example.harvest-post",
  "name": "Harvest Post",
  "version": "1.0.0",
  "authors": [
    "Play AC Online"
  ],
  "description": "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.",
  "scope": "world",
  "content": {
    "calendar": "calendar.json",
    "letters": "letters.json",
    "messages": "messages.json",
    "talk": "talk.json"
  },
  "scripts": {
    "main": "main.lua",
    "events": [
      "day_started",
      "scene_entered",
      "hour_changed",
      "question_answered",
      "command_finished",
      "timer_fired",
      "letter_read"
    ]
  },
  "permissions": [
    "send_letter",
    "show_line",
    "ask",
    "take_bells"
  ],
  "exports": {
    "fair_today": "true when today is the Harvest Fair in this town, else false."
  },
  "settings": [
    {
      "name": "present",
      "type": "choice",
      "label": "Present in the daily letter",
      "description": "Fruit puts a piece of fruit in each day's letter. None sends the letter alone.",
      "choices": ["fruit", "none"],
      "default": "fruit"
    }
  ],
  "assets_original": true
}

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: Lua script (scene_entered, button_pressed, button_released, player_acted, timer_fired, command_finished), World mod. 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
D-pad right: the mod puts its own striped hat and shirt on the player with set_hat and set_shirt. The next press is spots, then checks, then your own clothes.
D-pad right: the mod puts its own striped hat and shirt on the player with set_hat and set_shirt. The next press is spots, then checks, then your own clothes.
D-pad left reads the weather with game.weather and sets the next with set_weather: here the light snow turns to a blizzard, and the mod says so.
D-pad left reads the weather with game.weather and sets the next with set_weather: here the light snow turns to a blizzard, and the mod says so.
D-pad up plays a reaction from the reactions bar with react: a dance, then hooray, then a pose. With R held, game.input says so and it is a spin.
D-pad up plays a reaction from the reactions bar with react: a dance, then hooray, then a pose. With R held, game.input says so and it is a spin.
D-pad down saves the town outdoors with cmd.save, then reads game.place to say which acre and square it was saved in.
D-pad down saves the town outdoors with cmd.save, then reads game.place to say which acre and square it was saved in.
Video: Three looks on D-pad right, light snow on left, a dance, a cheer and a spin on up, a save on down, a blizzard, then five digs with a shovel and the cheer a game minute later.

A World mod ("scope": "world") with one script, main.lua, on the D-pad, anywhere in town:

- **Right**: a striped, spotted or checked hat and shirt of the mod's own (hats/, shirts/), then your own clothes again. - **Left**: the weather. Light snow, a blizzard, then clear again. In the rain season it is light rain and a storm. - **Up**: a dance, hooray, a pose or thanks. With R held, a spin. - **Down**: save the town, then say where you are. - **Every fifth thing you do** (a dig, a swing, a door), your character cheers.

Setting the weather changes the town, so the mod is a World mod. It still does not count for a friend visit: only a World mod with textures, shops or items does, so two friends need not both have it. On a visit, friends see your reactions but the game's own hat and shirt: a mod's look draws only on your screen. The weather and the save are refused there, as the host's game decides them.

The buttons #

button_pressed gives the button's name: dpad_right, a, c_up and the rest. The script keeps one function per D-pad direction in a table, PRESS, and calls the one pressed. button_released is the same for letting go: the look plays its sound (cmd.play_sound("wear")) then. A mod may play at most 10 sounds a minute and show 20 lines a game day, so a long go at the buttons falls quiet until the next day.

A button is a button however it is played: a key, a controller or the touch pad, with the player's own key settings. Nothing reaches a mod while the player types.

Right: the look #

cmd.set_hat and cmd.set_shirt take a picture from the mod's own files: a 32 x 32 PNG with at most 16 colours and no see-through pixels, the same as an Able Sisters design. nil gives the player's own back. The pictures sit outside a textures/ folder, since they are not texture replacements.

The game saves nothing about a mod's look, so the pick is kept in store.player (this player, in their own town) and put back at every scene_entered, which also runs at the first scene of a session. On a visit or in The City store.player starts empty, and the look you came in stays on.

Left: the weather #

game.weather() says the weather now, { kind, intensity }. The script steps from clear to light to heavy and back to clear with cmd.set_weather. The game allows only weather it could roll on the day, snow from November 1 to February 24 and rain from February 25 to November 15, and refuses the rest at once with the code command-weather, so the script tries snow, then rain. A mod may change the weather 4 times a game day, and the game's own weather comes back the next day.

Up: reactions #

cmd.react plays a reaction from the reactions bar on the player's character, the same one friends see. game.input() is every button held right now, so game.input().r tells the script R is down as up is pressed: then it is a spin. A reaction needs the player free, so the game refuses one in a talk or mid-swing.

Down: save anywhere #

cmd.save saves the town as the Autosave setting does, outdoors and in free control only, and at most once every 10 seconds for all mods together. It returns an id; command_finished comes back with that id once the game has written the save (via is saved, or unchanged when nothing changed). Then game.place() gives the acre and the square of the town map the player stands on, and the script says it with cmd.show_line.

Every fifth thing: player_acted #

player_acted fires when the player starts one of the game's actions: a dig, a filled hole, a swing of the axe or the net, a cast, a shaken tree, a seat, a door. game.player() says what the player is doing now and the tool in their hand, and the script writes both in the mod log. It counts the actions in store.player and, on every fifth, sets a timer: the player is busy with the action that just started, so cmd.react("hooray") waits for timer_fired a game minute later. Its own cheer comes back as "reacted", which the script leaves out of the count.

Make your own #

This repository is one mod, laid out the way the GitHub import wants it: mod.json at the top, and a tag named for the version in mod.json.

1. Copy the repository to your own account. 2. Change "id" in mod.json to your own, like yourname.button-tricks. Ids that start with example. are kept for these examples, so the import refuses them. 3. Tag the commit with the version, like v1.0.0. 4. Push the commit and the tag. Then, in the game, open **Settings**, then **Mods**, and scroll to **Share a mod**. Sign in, answer the age question and accept the mod rules the first time, and type the code from your authenticator app. **Import from GitHub** shows under the upload form once the code is accepted. Paste github.com/<you>/<repository>@v1.0.0 there and choose **Import**.

To keep only some buttons, delete their functions and their line in PRESS, and their permissions and events in mod.json. playac-mod check tells you if anything still points at them.

The modding guide is at playaconline.com/modding.

media/ holds the pictures and the film the cookbook shows, with their captions in media/media.json. .playac/screenshots/ holds the listing's screenshots.

What goes in the mod's ZIP is decided by the pack rule, the same for playac-mod pack and the GitHub import:

- Left out: this repository's own files. Those are this README.md, CHANGELOG.md (it is sent beside the ZIP as the listing's changelog), LICENSE, the whole media/ folder with its pictures, film and media.json, and the screenshots (.playac starts with a dot). The game ignores the same files in any ZIP. - Kept: every other .json, .lua, .dds, .png, .txt and .md file.

Download Button Tricks as a ZIP, ready to install. It downloads from the example's release on GitHub.

Its 6 pictures are not text, so they are listed here by name. Each links to the file in the repository.

{
  "schema": 1,
  "api": 1,
  "id": "example.button-tricks",
  "name": "Button Tricks",
  "version": "1.0.0",
  "authors": [
    "Play AC Online"
  ],
  "description": "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.",
  "scope": "world",
  "scripts": {
    "main": "main.lua",
    "events": [
      "scene_entered",
      "button_pressed",
      "button_released",
      "player_acted",
      "timer_fired",
      "command_finished"
    ]
  },
  "permissions": [
    "set_hat",
    "set_shirt",
    "set_weather",
    "react",
    "save",
    "play_sound",
    "show_line"
  ],
  "assets_original": true
}

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.

A thank-you letter after spending Bells at Nook's #

Counts what each player spends at Nook's and mails a thank-you once they pass 10,000 Bells. It also logs every sale.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.big-spender",
  "name": "Big Spender",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "content": {
    "messages": "messages.json"
  },
  "scripts": {
    "main": "main.lua",
    "events": [
      "item_bought",
      "item_sold"
    ]
  },
  "permissions": [
    "send_letter"
  ],
  "assets_original": true
}
  • A catalog order fires item_bought too, with e.ordered true. It is paid now and mailed tomorrow.
  • On a friend's town the letter is refused (command-visiting): only the town owner's game mails letters.

A Saturday fruit market at the flower shop #

Every Saturday the flower shop sells only cherries and pears, and it stays open through the night. A script decides it each morning, so the rule can be anything a script can read.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.saturday-market",
  "name": "Saturday Market",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "world",
  "scripts": {
    "main": "main.lua",
    "events": [
      "day_started"
    ]
  },
  "permissions": [
    "set_shop_goods",
    "set_shop_open"
  ],
  "assets_original": true
}
  • A script's change is one more block after the mod's own shops.json blocks for that shop. It is gone when the day changes or the game restarts.
  • It is refused when a mod later in the load order changes the same shop, or when the shop has no goods or no open in the shop table.

Swap an item for another #

Once a day, asks the player for an apple and gives a pear back. cmd.take_item asks with the game's own question, so the player always agrees first.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.fruit-swap",
  "name": "Fruit Swap",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "scripts": {
    "main": "main.lua",
    "events": [
      "scene_entered",
      "command_finished"
    ]
  },
  "permissions": [
    "take_item",
    "give_item"
  ],
  "assets_original": true
}
  • A take is refused at once with command-not-held when the pockets do not hold the item.
  • A take sends no question_answered. Its one result is command_finished.
  • Takes are refused on a visit and in The City.

A hotkey: a button combination #

Hold L and press Z: says the time, or the date with the stick pushed up. A keyboard, a controller and the touch pad all reach a script as the same buttons.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.clock-key",
  "name": "Clock Key",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "scripts": {
    "main": "main.lua",
    "events": [
      "button_pressed",
      "button_released"
    ]
  },
  "permissions": [
    "show_line"
  ],
  "assets_original": true
}
  • game.input() reads every button held and the main stick when the handler runs. On a busy frame an event can run a frame or two after the press, so a combination is safest tracked from the events, as holding_l is here.
  • The game still gets every press, so pick a combination it does not use, or a moment where the button does nothing.
  • A script never sees which key was typed. While the player writes a letter or a name, nothing reaches it and game.input() is nil.

Save the game each time the player steps outside #

cmd.save() saves the town where the player could save at Gyroid. This mod asks for a save every time the player comes back outdoors, and says so when the game wrote one.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.step-out-save",
  "name": "Step Out Save",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "scripts": {
    "main": "main.lua",
    "events": [
      "scene_entered",
      "command_finished"
    ]
  },
  "permissions": [
    "save",
    "show_line"
  ],
  "assets_original": true
}
  • The game saves only outdoors in the player's own town, in free control. Indoors the save is refused with command-indoors and nothing is written.
  • The save never changes the town being played, so it cannot lose or double an item.
  • via is "unchanged" when nothing changed since the last save. Only a save that wrote the town counts against the day's cap.
  • Saves by mods are at least a few seconds apart, and every save uploads the town to the cloud, so never save on a timer: the Autosave setting does that.
  • A save is refused on a visit and in The City.

Play a jingle when a fish is caught #

cmd.play_sound plays one of the game's own sound effects, by its name in sounds.json. This mod plays the item jingle when the player catches a fish worth keeping.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.catch-jingle",
  "name": "Catch Jingle",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "scripts": {
    "main": "main.lua",
    "events": [
      "fish_caught"
    ]
  },
  "permissions": [
    "play_sound"
  ],
  "assets_original": true
}
  • Only the player whose game runs the mod hears the sound. On a visit the friend does not hear it.
  • A sound plays at once, in a talk or a menu too: it does not wait for the player to be free.
  • Every sound in sounds.json plays once and stops on its own. None loops.
  • A few sounds per event and a few per minute: play one for a moment that matters.

A rainy morning that clears by noon #

cmd.set_weather sets the town's weather for the rest of the game day. This mod makes it rain at 8 in the morning and clears the sky at noon, and in the snowy months it snows instead.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.rainy-morning",
  "name": "Rainy Morning",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "world",
  "scripts": {
    "main": "main.lua",
    "events": [
      "hour_changed",
      "command_finished"
    ]
  },
  "permissions": [
    "set_weather"
  ],
  "assets_original": true
}
  • Only weather the game itself could roll that day is allowed: no rain in the snowy months, no snow from late February to October, and only clear on the days the game keeps clear, such as New Year and the cherry blossoms.
  • The change waits for the player to be free, then the drops or flakes fade in as the game's own weather does. via is "unchanged" when the town already had that weather.
  • It needs "scope": "world": a friend visiting sees the same weather. A visitor's game needs no copy of the mod for it.
  • The weather is refused on a visit and in The City. The next game day the game picks its own weather again.

A setting only its own player sees #

A World mod with a setting each player keeps for themselves: whether a line greets them each morning.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.morning-line",
  "name": "Morning Line",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "world",
  "content": {
    "messages": "messages.json"
  },
  "scripts": {
    "main": "main.lua",
    "events": [
      "day_started"
    ]
  },
  "permissions": [
    "show_line"
  ],
  "settings": [
    {
      "name": "greet",
      "type": "bool",
      "label": "Say good morning",
      "default": true,
      "scope": "client"
    }
  ],
  "assets_original": true
}
  • "scope": "client" makes the value the player's own. A friend visit never compares it, and on a visit each player runs their own value.
  • A client setting may decide only what its own player sees or hears. In an event that read one, send_letter, give_item, take_item and take_bells are refused with command-client-setting. show_line and ask still work.
  • In a Just you mod the scope changes nothing a visit sees. The script kit's setting leaves it out.

Remember something in this browser, whatever the town #

store.client is one store per mod per browser. store keeps a value per town and store.player per resident.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.day-counter",
  "name": "Day Counter",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "scripts": {
    "main": "main.lua",
    "events": [
      "day_started"
    ]
  },
  "assets_original": true
}
  • store.client answers the same in every town played in this browser. store and store.player travel with the town.

Change the shape of saved data #

Version 2 of a mod renames a store key. data_migrated runs once per town, before any other handler there.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.visit-count",
  "name": "Visit Count",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "data_version": 2,
  "scripts": {
    "main": "main.lua",
    "events": [
      "data_migrated",
      "scene_entered"
    ]
  },
  "assets_original": true
}
  • e.from is 0 for data written before the mod had a data_version. If the handler errors, the script stops and the next start tries again.

Notice a new villager, or a friend riding in #

villager_moved_in fires at the game start after a villager moved in. visitor_arrived fires in the host's game when a friend is on the way.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.arrivals",
  "name": "Arrivals",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "scripts": {
    "main": "main.lua",
    "events": [
      "villager_moved_in",
      "visitor_arrived"
    ]
  },
  "permissions": [
    "show_line"
  ],
  "assets_original": true
}
  • A brand-new town fires villager_moved_in for its first villagers too.

A weather report on the hour: where you are and what is falling #

Every game hour, while the player is outdoors, says the acre they stand in and the weather there. Indoors it stays quiet.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.weather-report",
  "name": "Weather Report",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "scripts": {
    "main": "main.lua",
    "events": [
      "hour_changed"
    ]
  },
  "permissions": [
    "show_line"
  ],
  "assets_original": true
}
  • kind is clear, rain or snow, the words shops and talk pools use. Cherry blossom petals and falling leaves count as clear.
  • p.acre is the town map's label, like "C-3", and is nil indoors. unit_x and unit_z say which of the acre's 16 by 16 squares, never anything finer.
  • Neither query needs a permission: reading changes nothing. Both are nil before a town is loaded.

Need another mod, or refuse to run with one #

"depends" names mods this one needs: it loads after them and not at all without them. "conflicts" names mods it cannot run with. message() reads another mod's line by its full key.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.tea-talk",
  "name": "Tea Talk",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "scripts": {
    "main": "main.lua",
    "events": [
      "villager_talked"
    ]
  },
  "depends": {
    "yourname.tea-lib": ">=1.0.0 <2.0.0"
  },
  "conflicts": {
    "someone.other-tea": "*"
  },
  "assets_original": true
}
  • A mod id goes in only one of depends, optional_depends and conflicts.
  • For a mod yours can use but does not need, see optional_depends in the script kit and the dependencies guide.

Small talk for the weather, the season and the time of day #

Villagers say your lines as their small talk, when you choose to chat. A pool can be kept to one personality, to rain or snow, or to a season and a time of day. No code.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.weather-talk",
  "name": "Weather Talk",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "content": {
    "talk": "talk.json"
  },
  "assets_original": true
}
  • season is spring, summer, fall or winter. time is morning (5 to 12), day (12 to 17), evening (17 to midnight) or night (midnight to 5). weather is clear, rain or snow.
  • The most specific pools that fit decide: the villager by name, else their personality, else everyone. A cranky villager only ever gets the cranky pool here, rain or not.
  • chance is in how many talks in 100 a fitting pool speaks. Leave it out for every one. When every pool that fits rolls no, the villager makes the game's own small talk.

Lines anywhere in a talk: before, hello, topic, after, the whole conversation #

A pool's place puts its lines before the hello, as the hello, as the topic after a chat answer, after the topic, or as the whole conversation. A line can be a list of pages. No code.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.town-talk",
  "name": "Town Talk",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "content": {
    "calendar": "calendar.json",
    "talk": "talk.json"
  },
  "assets_original": true
}
  • before keeps the hello. hello replaces an everyday hello only; a hello with news is kept. The menu follows either.
  • topic replaces the topic the game picked after a chat answer when it is one of topics (small_talk when you name none, "any" for all six). The talk ends after it. A trade it replaces does not happen.
  • after is the last message of a chat. conversation is the whole talk: no hello, no menu, no topic.
  • day is the id of a day in the same mod's calendar file: it is how a calendar day gets villager lines. On the day, a day's pools come ahead of every other pool of their place. Each place picks its own line, so one talk can have a before, a hello, a topic and an after line.

A villager asks the player something #

A script's conversation takes the whole talk and ends in a question. The player's pick goes to villager_answered, which says what comes next and may ask again.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.bake-sale",
  "name": "Bake Sale",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "client",
  "scripts": {
    "main": "main.lua",
    "events": [
      "villager_talked",
      "villager_answered"
    ]
  },
  "assets_original": true
}
  • ask has 2 to 4 choices of up to 16 characters. e.choice counts from 1; e.text is the answer picked.
  • Return nil from villager_answered and the talk ends.
  • A conversation needs every place in the talk free, so put the mod high in the list if another mod's script talks too.
  • The list of who was asked is in memory: everyone is asked again after a restart.

Rename a mod item players already have #

Never change an item's id once players have it. To rename one, map the old full id to the new one with "renames". It runs once per save.

{
  "schema": 1,
  "api": 1,
  "id": "yourname.lamps",
  "name": "Lamps",
  "version": "1.0.0",
  "authors": [
    "yourname"
  ],
  "scope": "world",
  "content": {
    "items": "items.json"
  },
  "renames": {
    "yourname.lamps:old-lamp": "yourname.lamps:ghost-lamp"
  },
  "assets_original": true
}
  • Both sides of a rename are this mod's own ids. An item of another mod cannot move into yours.

Try a recipe #

  1. Download its ZIP above, or copy its files into a folder with the same names.
  2. 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 #

  1. Make a copy of the recipe's repository on GitHub, or download its ZIP and put the files in a new repository.
  2. Change the id in mod.json to your own, such as yourname.something, and set your own name.
  3. Tag a release named for the version in mod.json, such as v1.0.0.
  4. 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.