Modding Help [SMAPI] Accessing sheds and the Greenhouse

Discussion in 'Mods' started by TheCroak, Oct 17, 2016.

Tags:
  1. TheCroak

    TheCroak Space Hobo

    Hello, I'm currently writing a mod notifying when a product is ready for harvest in sheds or the greenhouse. To achieve this, I plan on iterating on objects inside of the building.

    However, it seems I can't access them from Game1.getLocationFromName("Shed") and they aren't in Game1.locations

    Am I missing something or is there currently no way to access sheds and such with SMAPI ?
     
    • VIspReaderUS

      VIspReaderUS Void-Bound Voyager

      aren't sheds buildings? So get buildings and getinner, I think
       
      • TheCroak

        TheCroak Space Hobo

        Yes, I actually found that just before I went back to that thread hahaha

        That's how I did it:



        Code:
                    List<Building> buildings = ((Farm)Game1.getLocationFromName("Farm")).buildings;
        
        
        
                    foreach (Building building in buildings)
                    {
        
                        if (building.baseNameOfIndoors == "Shed")
                        {
                            foreach (StardewValley.Object obj in building.indoors.objects.Values) {
                                if (obj.readyForHarvest) {
                                    Log.Info((object)"Shed harvest ready message !");
                                    return;
                                }
        
                            }
                        }
        
        
                    }
        
                    Log.Info((object)"Nothing ready to harvest in the sheds.");
        
        
        Thank you for your help ! My post will soon be ready to release once I've done a bit more testing and added some fluff
         
          foghorn likes this.

        Share This Page