Skip to content
Jack Burkhardt edited this page Sep 17, 2022 · 1 revision

All emails are stored in a text file using JSON format, and then loaded at runtime into an inbox list. All emails in the game will be stored in this file, but "sending" an email (setting Available to true) will make it actually visible to the player in game. The current location of the email inbox is at Assets/GameData/Emails/inbox.json.

Adding new emails

Here is a example email you can copy and edit:

  {
    "Sender": "Steve Becker",
    "Recipient": "Ava",
    "Subject": "An idea for managing finances",
    "BodyText": "Hi Ava, \n\ntake a look at these pictures andlet me know what you think. \n\nThis could be big.",
    "BodyImagePaths": [
      "idea-image1.png",
      "idea-image2.jpg"
    ],
    "Read": false,
    "Available": true
  }

Here's what each part of the above email means:

  • Sender: Self explanatory. The name of the character sending the email.
  • Recipient: Usually the player's name, but could be someone else's name if it's a forwarded email.
  • Subject: Subject of the email, also what the file should be named.
  • BodyText: Body of the email. (NOTE: JSON and C# can't directly take multi-line strings, so you'll need to format them using escape characters)
  • BodyImagePaths (optional): A list of the locations of images that can be embedded in the email. These should be the path of the image relative to the Emails folder. In this case, these images are just in the /Assets/GameData/Emails/ folder.
  • Read: If the email has been read or not. Should be false by default unless you really need it, as setting true could break some things.
  • Available: Whether the email is currently viewable in the player inbox (in game terms, this is true if the email has been "sent" to the player.

You can check the correctness of your JSON formatting here.

Sending emails to the player

You can send emails to the player in Yarn by calling the deliver_email command in your yarn script or by calling EmailBackend.DeliverEmail in code.

Clone this wiki locally