Stardew Valley
0 of 0

File information

Last updated

Original upload

Created by

Digus

Uploaded by

Digus

Virus scan

Safe to use

About this mod

Framework to use the in game mailbox. Console commands to adjust the mail. Code and Content Pack interfaces.

Requirements
Permissions and credits
Changelogs
Objective:
Simplify the send of mail to the player, giving more control over when and what should be received.
Also giving more options not possible just editing the data files, like changing the text color and background of the letter at will.

Installation:
  1. Install the latest version of SMAPI.
  2. Unzip the MailFrameworkMod into /Stardew Valley/Mods.

Change Log:

1.7.0
  • Support for Rings as attachments.
  • New conditions for recipes.
  • New property for background customization with content packs.
  • Support to Close Button customization with content pack and code.
1.6.0
  • Support to i18n in content packs.
  • New conditions properties for buildings in the farm.
  • New conditions properties for mail received. (this is used for quest flags)
  • New conditions properties for events.
  • New conditions list for collections menu items.
  • New conditions list for game stats.
  • New property for friendship status for the conditions list for NPC friendship.
  • New random functionality for when Group Ids collide.
1.5.1
  • Fix to letters with no group ids being grouped together.
1.5.0
  • Letter will now be shown in the collection menu if an Title is defined. Custom textures and color will also show in the collection menu.
  • Letter now can have a group id. Letter with the same group id are never delivered in the same day.
  • New condition for content packs: "RandomChance".
  • BigObject is now called BigCraftable, like in the game code.
  • Fix of typos in the template.
1.4.1
  • Adds support to Stardew Valley 1.4.0
  • Adds Title property for Letters to be shown in the collection menu. Not fully implemented yet, but modders can start to set it.
1.4.0
  • Adds an content pack support for modders to add custom letters, with configurations to all features this framework provides, and with mostly common used delivery conditions.
  • Fix controllers not working to get attached items.
  • Fix to properly show attachments if the mail has more than one item attached.
  • Fix to not let the letter close if your inventory is full and a menu is opened to manage it.
  • Fix to not adding an stack of items to the mail even when configured to.
  • Adds support to SMAPI 3
1.3.4
  • Adds support to Stardew Valley 1.3.36
1.3.3
  • Adds support to SMAPI 3
1.3.2
  • Adds support to Stardew Valley 1.3.32
1.3.1
  • Adds commands to remove and add to the player received mail list.
1.3.0-beta.6
  • Adds support to crafting recipes
  • Adds support to custom background
  • Adds support to custom text color
  • New way to open custom letter, now using harmony
  • Config file to enable old way of opening custom letters.
1.2.0
  • Support to i18n recipes.
  • Fix to the mod not working properly after returning to title menu.
  • Fix to no mail being delivered if the condition of a letter threw an exception.
1.1.0
  • Fix to receiving "tax passed" mail when sleeping and quit the game without having read a custom mail.
  • Custom mails can have recipes.
  • This version is not compatible with the older one. Mods need to be updated to use this version.
1.0.0
  • Add custom mails
  • Custom mails can have items.

For Modders to use content pack:
  • There is a template inside the mod folder with commented instructions on what each property do.
  • All letter features but the conditions and callback are the same as coding with the framework.
  • Conditions are limited to the ones implemented, and the callback always set the letter id as received. If you need advanced conditions you still should code them. Or you can politely suggest me to add a condition to the content pack, if its something that makes sense, I might add it.
  • Here is the template as added in the mod file:
Spoiler:  
Show



For Modder to code:
  • Reference the MailFrameworkMod.dll on your SMAPI project.
    • You register your Letter using MailDao.SaveLetter(Letter)
    • At the begin of each day the mod will check for Letters that have reached its condition for delivery and add them to the mailbox.
    • This Letters will be opened first when the player check the mailbox.
    • When the Letter is opened, it is removed from the mailbox.
    • The callback condition of the letter is them called.
    • At the end of the day Letter still on the mailbox will be removed, so they are not saved by the game.
  • You can think of this mod as an repository for your letters. It works best if you load all your letter when the game loads.


Exemples:
Loading a simple Letter that will show for the player if not read before, and will not be be delivered again after being opened by the player:
MailDao.SaveLetter(
new Letter(
"LetterUniqueId"
,"Letter custom text."
,(l)=>!Game1.player.mailReceived.Contains(l.Id)
,Game1.player.mailReceived.Add(l.Id)
)
);


Loading a simple Letter as before, but with 5 Emerald annexed:
MailDao.SaveLetter(
  new Letter(
"LetterUniqueId"
,"Letter custom text."
,new List<Item> { new StardewValley.Object(60,5) }
,(l)=>!Game1.player.mailReceived.Contains(l.Id)
,Game1.player.mailReceived.Add(l.Id)
  )
);

The player will not receive the same item, but a copy returned from the getOne() method.

Loading a simple Letter that will teach a cooking recipe, it will be delivered if the player doesn't know the recipe. The mod automatically teaches the recipes when the player loads, no need for a callback here:
MailDao.SaveLetter(
  new Letter(
"LetterUniqueId"
, "Letter custom text."
, "RecipeUniqueName"
, (l) => !Game1.player.cookingRecipes.ContainsKey(l.Recipe)
  )
);

The "RecipeUniqueName" must be the same as stored on "Data//CookingRecipes" or "Data//CraftingRecipes".

Loading a simple Letter with different text and background:
MailDao.SaveLetter(
  new Letter(
"LetterUniqueId"
,"Letter custom text."
,(l)=>!Game1.player.mailReceived.Contains(l.Id)
,Game1.player.mailReceived.Add(l.Id)
1
  ){TextColor=8}
);


Loading a simple Letter with custom background:
MailDao.SaveLetter(
  new Letter(
"LetterUniqueId"
,"Letter custom text."
,(l)=>!Game1.player.mailReceived.Contains(l.Id)
,Game1.player.mailReceived.Add(l.Id)
1
  ){
LetterTexture=helper.Content.Load<Texture2D>("CustomLetterBG.png")
,TextColor=4
  }
);
Where CustomLetterBG.png is a image file that follows the same structure as "LooseSprites//letterBG"

For more info:
https://community.playstarbound.com/threads/mail-framework-mod.145900/