I have made a mail object but it does not open.

Ron47

Newcomer
my code:


using System;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewModdingAPI.Utilities;
using StardewValley;

namespace ***
{
public class MyModMail : IAssetEditor
{
public MyModMail()
{
}

public bool CanEdit<T>(IAssetInfo asset)
{
return asset.AssetNameEquals("Data\\mail");
}

public void Edit<T>(IAssetData asset)
{
var data = asset.AsDictionary<string, string>().Data;

// "MyModMail1" is referred to as the mail Id. It is how you will uniquely identify and reference your mail.
// The @ will be replaced with the player's name. Other items do not seem to work (''i.e.,'' %pet or %farm)
// %item object 388 50 %% - this adds 50 pieces of wood when added to the end of a letter.
// %item tools Axe Hoe %% - this adds tools; may list any of Axe, Hoe, Can, Scythe, and Pickaxe
// %item money 250 601 %% - this sends a random amount of gold from 250 to 601 inclusive.
// For more details, see: https://stardewvalleywiki.com/Modding:Mail_data
data["MyModMail1"] = "Hello @... ^A single carat is a new line ^^Two carats will double space.";
data["MyModMail2"] = "This is how you send an existing item via email! %item object 388 50 %%";
data["MyModMail3"] = "Coin $ Star = Heart < Dude + Right Arrow > Up Arrow `";
data["MyWizardMail"] = "Hello^^-Razmodius ^ %item object 388 50 %%";
}
} /// <summary>The mod entry point.</summary>
public class ModEntry : Mod
{
/*********
** Public methods
*********/
public override void Entry(IModHelper helper)
{
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
}

/*********
** Private methods
*********/
private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
{
Helper.Content.AssetEditors.Add(new MyModMail());
}
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{
// ignore if player hasn't loaded a save yet
if (!Context.IsWorldReady)
return;
Game1.player.mailbox.Add("MyModMail1");
}
}
}
 
Top