Modding Help (Solved) Please help me with Json Assets and Mail Framework

Discussion in 'Mods' started by ClickScrollDown, May 20, 2019.

  1. ClickScrollDown

    ClickScrollDown Space Hobo

    Hey. I need someones help to explain how to put an item created with Json Assets into a letter created with the Mail Framework Mod. In my case I already have my working asset, a tree sapling, that's added to the game and I have a letter appearing in the mail box. I think I have the part of my code correct that gets the sapling ID which is 10. However If I put the ID in the format provided by the Mail Framework mod, the item appears in the letter as an "Error Item". My guess is my code is searching Stardew Valley for ID 10 which doesn't exist rather than the Json Asset directory. Anyways I'm not sure how simple or complex this question is since I'm new at this but any help is welcome.

    Here's the format for the Mail Framework Mod I used from the Nexus Page:
    Code:
    //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)
      )
    );
    Here's my code pertaining to the Letter:
    Code:
    private readonly string[] Names = {
      "Scented Tree"
      };
    
    foreach (string name in this.Names)
      {
      int id = this.JsonAssets.GetFruitTreeId(name);
      Letter letter = new Letter("TheScentedTreeLetter"
      , "Letter body here..."
      , new List<Item> { new SObject(id, 1) } //This puts a Stardew object with ID 10 in the letter
      , (l) =>
      {
      return !Game1.player.mailReceived.Contains(l.Id)
      && (GetNpcFriendship("Wizard") >= 3 * 250); //Wizard needs 3 hearts for the letter to appear
      }, (l) => Game1.player.mailReceived.Add(l.Id)
      );
      MailDao.SaveLetter(letter);
    }
    Link to the JsonAssets API.
    Link to the Mail Framework Nexus page.
    Link to the JsonAssets Nexus page.
     
    • MouseyPounds

      MouseyPounds Cosmic Narwhal

      A fruit tree ID is different from the object ID of your sapling. (Stardew has multiple different collections of IDs which can be confusing). You'll want to change to something like
      Code:
      int id = this.JsonAssets.GetObjectId(name);
      but the "name" in this case would need to be the "SaplingName" defined in the JA definition for that tree.
       
        ClickScrollDown likes this.
      • ClickScrollDown

        ClickScrollDown Space Hobo

        Wow your the best! You saved me so much time. I'm sure this will be a good reference for those trying to use those two mods.

        Changed:
        int id = this.JsonAssets.GetFruitTreeId(name);
        to
        int id = this.JsonAssets.GetObjectId(name);
         
        • paradigmnomad

          paradigmnomad Scruffy Nerf-Herder

          Marking this for reference since I've always wanted to incorporate mail into PPJA.
           

          Share This Page