Tool SMAPI: Stardew Modding API

Discussion in 'Mods' started by ClxS, Mar 6, 2016.

Thread Status:
Not open for further replies.
  1. Oranisagu

    Oranisagu Subatomic Cosmonaut

    well.. it's not totally automatic, but resharper is a LOT smarter about missing references and usually it just takes one Alt+Enter, Enter to fix it. at least for me =) the license cost is a bit high for personal use though IMHO, but fortunately there are ways around that.
     
    • Bunkmaster

      Bunkmaster Space Spelunker

      I'm not a modder but I understand a little of how it works and this sounds amazing. Great work!
       
      • Consillium

        Consillium Poptop Tamer

        Does anyone have any guides or experience in altering NPC movement, for example, if I wanted an NPC to follow the player. I've been playing around with it a bit but the NPCs don't seem to react to my movement calls.
         
        • kodfod

          kodfod Void-Bound Voyager

          So i used this in GameEvents.UpdateTick event, and it's not perfect, but it works.

          Code:
          try
            {
              // Get all npc's on this map.
              List<NPC> npcs = Game1.currentLocation.characters;
              //Iterate all of them and move them to you.
              foreach (NPC c in npcs)
              {
                // Only update the locations and play animations when moving.
                if (Game1.player.isMoving())
                  {
                     //Make the npc face the general direction of the player.
                     c.faceGeneralDirection(Game1.player.getStandingPosition(), 0);
                     // Update the sprite to face the new direction.
                     c.setMovingInFacingDirection();
                     // Animate the sprite...
                     c.animateInFacingDirection(Game1.currentGameTime);
                     // Now move very smoothly.
                     c.lerpPosition(Game1.player.position);
                  }
              }
            } catch (Exception ee)
              {
              // Catch exceptions: npc's will be null when starting game.
            }
           
          • iamMiKA

            iamMiKA Void-Bound Voyager

            Alright, I thought the train got bugged because of mods and I'm afraid it'll also break more events.
            I was ready to start all over again lol.

            Do you mind telling we what kinds of mod you use? do you use timespeed?
             
            • Consillium

              Consillium Poptop Tamer

              Thanks! I like how "very smoothly" means "suddenly apparate" :p.
               
                Last edited: Apr 3, 2016
                kodfod likes this.
              • Raspberry Lemonade

                Raspberry Lemonade Void-Bound Voyager

                So... Nothing super huge for me but with beta turned on and launched through SMAPI, the game will freeze on the blue screen right after character creation and will also freeze on the start screen when starting up Journey of the Prairie King. Like I said not a major thing as I can just turn off beta and it'll work but thought it might be something to note.
                 
                • kodfod

                  kodfod Void-Bound Voyager

                  You're welcome! Also you could make the npc move in that general direction, but in my tests I found they would not get close to you. If you got close they would get mad and charge away into the abyss never to be seen again. lerping their position is the only way I was able to get them to follow, but it does break their schedule.... I'm interested as to what you got planned for this power.....
                   
                  • Consillium

                    Consillium Poptop Tamer

                    Heh, I'm working on a pet enhancement mod, that would allow your pet to follow you as you go about your day, and maybe even bring you items. The first step was seeing if I can get an NPC to follow you on on command, but it is proving challenging...
                     
                    • sweetangel20

                      sweetangel20 Starship Captain

                      That sounds amazing! Good luck!
                       
                      • Superior_s

                        Superior_s Sandwich Man

                        I know it isn't currently available but how will the Xnb merging work?
                         
                        • Koihime Nakamura

                          Koihime Nakamura Ketchup Robot

                          It's also acting up in the mines. I suspect there will be a delay once beta hits stable before SMAPI catches up.
                           
                          • ClxS

                            ClxS Pangalactic Porcupine

                            At the moment it only works with textures, I'll have a look at how to do it for non-texture formats.

                            But how it basically works is in your manifest you register textures (pngs) for the API to load/provide you easy access to. In the same manifest you can select to replace XNBs, or to replace a certain part of a an XNB.
                            In that case, load the base texture using the ordinary ContentLoader, load your texture, copy the base texture into a new texture, and write your changes over top of it. This result is then cached so that it doesn't have to be redone/reloaded each time it's required which could be a lot for some sprites.

                            I've just started migrating my preview version into a public repository here: https://github.com/ClxS/Stardew-Revolution. There's still a fair bit of work to do and some things like the Command functionality aren't there yet - but they're on the way slowly but surely.
                             
                            • Yunix

                              Yunix Big Damn Hero

                              Uhm, this will be a little bigger list:
                              1. SMAPI 0.39.6
                              2. All Crops All Seasons
                              3. All Professions
                              4. Automated Animal Doors
                              5. CJB Automation
                              6. CJB Cheats Menu
                              7. CJB Item Spawner
                              8. Daily Friendship Increaser
                              9. Display Grid
                              10. Instant Geode
                              11. Instant Grow Trees
                              12. Jiggly Junimo Bundles
                              13. NPC Map Locations
                              14. Simple Sprinkler
                              15. Skull Cave Saver
                              16. CJB Show Item Sell Price
                              17. Wait Around
                              18. Bigger Greenhouse
                              And a very huge amount of xnb graphic mods and custom edits.
                               
                              • Orcus187

                                Orcus187 Space Hobo

                                When installed SMAPI i had a few thing to do:
                                1. .NET Framework 4.5 install
                                2. Set in StawdewModdingAPI.exe the propertys to start as administrator.
                                3. Set in Stawdew Valley.exe the propertys to start as administrator.
                                (4. Add the steam_appid.txt into the Stardew Valley.exe folder.)
                                (5. Change in Steam the gamestart option to "YOUR PATH\Stardew Valley\StardewValleyModdingAPI.exe" %command% )
                                (Dont remove the "" an change YOUR PATH to your path.)
                                (6. Set in Steam.exe the propertys to start as administrator and restart steam.)

                                The 4, 5 and 6 you only need to do if you want to start it with steam and get the time, archievements and overlay.

                                Oh, and maybe you should get the latest version of SMAPI (at the moment it is v0.37.3).
                                Yunix,Mar 14, 2016

                                [​IMG]
                                [​IMG]

                                I cannot seem to get steam overlay to work while running the api.exe. I changed the path in steam but i cannot figure out what im doing wrong to get the steam overlay to work correctly. Any help would be greatly appreciated. Thanks in advance
                                 
                                • Rui

                                  Rui Scruffy Nerf-Herder

                                  Hello! I've been stalking this thread for awhile now. I would REALLY love to try my hand at helping out with this API... thing is I have no such experience in making APIs, and while I have a good handle on C I'm still learning my way around C#. Mostly for the past week I've just been staring at the Stardew Valley code, the SMAPI code and reading up on C# tutorials and puzzling over things such as reflection and lambda expressions... and I have a feeling I'll still be doing this for awhile. :rofl:

                                  I have a mod in mind, but I don't think I'll be able to pull it off until SMAPI is further along. Ooorr... until whatever is replacing SMAPI comes? :rofl: I'm a bit confused... Is the SMAPI source code not the new API you're working on? Though I have a feeling I won't really be able to help for awhile until I get my bearings more even if I know what's going on.

                                  I'm glad to see that there is a team actively working on this! Can't wait to see where modding with this game will go. There's so much potential! <3
                                   
                                  • KotatsuNiMikan

                                    KotatsuNiMikan Intergalactic Tourist

                                    Does anyone else have problem with using SMAPI 0.39.6 on version 1.07f(beta)?
                                    Game will freeze when you try to play pirate king,
                                    and also freeze during Haley's heart 8 event.
                                    There might be other events or actions can cause same kind of freeze.

                                    Console says something about an error occurred in the overridden update loop
                                    : System.NullReferenceException
                                    at StardewModdingAPI.Inheritance.SGame.get_ThumbstickMotionMargin()
                                    at StardewModdingAPI.Inheritance.SGame.Update(GameTime gameTime)
                                     
                                    • Superior_s

                                      Superior_s Sandwich Man

                                      Thanks for the response, so how would you go about setting it to replace certain parts, I understand that you edit your manifest to include it, but how do you single out certain parts of the image?
                                       
                                      • ClxS

                                        ClxS Pangalactic Porcupine

                                        Superior_s likes this.
                                      • l3l4ckR4sp3rry

                                        l3l4ckR4sp3rry Void-Bound Voyager

                                        I have got a problem starting SMAPI.
                                        In my ErrorLogs is allways

                                        [08:46:08.527 ] Game failed to start: System.MissingMethodException: Method not found: 'Int32 StardewValley.Game1.getMouseX()'.
                                        at StardewModdingAPI.Inheritance.SGame.Update(GameTime gameTime)
                                        at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
                                        at StardewModdingAPI.Program.RunGame()

                                        [08:46:07.511 ] Validating api paths...
                                        [08:46:07.526 ] Initializing SDV Assembly...
                                        [08:46:07.526 ] Injecting New SDV Version...
                                        [08:46:07.526 ] Starting SDV...
                                        [08:46:07.558 ] Patching SDV Graphics Profile...
                                        [08:46:07.558 ] LOADING MODS
                                        [08:46:07.558 ] Found Manifest: D:\Games\Stardew Valley Modded\Mods\HealthBars\manifest.json
                                        [08:46:07.698 ] Created psconfigs directory @D:\Games\Stardew Valley Modded\Mods\HealthBars\psconfigs
                                        [08:46:07.698 ] Loading Mod DLL...
                                        [08:46:07.698 ] LOADED MOD: Health Bars by Zoryn - Version StardewModdingAPI.Version | Description: Shows monster health bars. (@ D:\Games\Stardew Valley Modded\Mods\HealthBars\HealthBars.dll)
                                        [08:46:07.714 ] HealthBars by Zoryn => Initialized (Press F5 To Reload Config)
                                        [08:46:07.714 ] Found Manifest: D:\Games\Stardew Valley Modded\Mods\MovementMod\manifest.json
                                        [08:46:07.714 ] Created psconfigs directory @D:\Games\Stardew Valley Modded\Mods\MovementMod\psconfigs
                                        [08:46:07.714 ] Loading Mod DLL...
                                        [08:46:07.714 ] LOADED MOD: Movement Modifier by Zoryn - Version StardewModdingAPI.Version | Description: Allows you to change movement based on a config (@ D:\Games\Stardew Valley Modded\Mods\MovementMod\MovementMod.dll)
                                        [08:46:07.729 ] MovementMod by Zoryn => Initialized (Press F5 To Reload Config)
                                        [08:46:07.729 ] Found Manifest: D:\Games\Stardew Valley Modded\Mods\RegenMod\manifest.json
                                        [08:46:07.729 ] Created psconfigs directory @D:\Games\Stardew Valley Modded\Mods\RegenMod\psconfigs
                                        [08:46:07.729 ] Loading Mod DLL...
                                        [08:46:07.729 ] LOADED MOD: Regen Mod by Zoryn - Version StardewModdingAPI.Version | Description: Allows the player to regen health and stamina based on config values (@ D:\Games\Stardew Valley Modded\Mods\RegenMod\RegenMod.dll)
                                        [08:46:07.745 ] RegenMod by Zoryn => Initialized (Press F5 To Reload Config)
                                        [08:46:07.745 ] Found Manifest: D:\Games\Stardew Valley Modded\Mods\StardewCJB\manifest.json
                                        [08:46:07.760 ] Created psconfigs directory @D:\Games\Stardew Valley Modded\Mods\StardewCJB\psconfigs
                                        [08:46:07.760 ] Loading Mod DLL...
                                        [08:46:07.760 ] LOADED MOD: CJB Show Item Sell Price by CJ Bok - Version StardewModdingAPI.Version | Description: Show item sell price in your inventory! (@ D:\Games\Stardew Valley Modded\Mods\StardewCJB\StardewCJB.dll)
                                        [08:46:07.760 ] Found Manifest: D:\Games\Stardew Valley Modded\Mods\TimeSpeed\manifest.json
                                        [08:46:07.760 ] Created psconfigs directory @D:\Games\Stardew Valley Modded\Mods\TimeSpeed\psconfigs
                                        [08:46:07.760 ] Loading Mod DLL...
                                        [08:46:07.760 ] LOADED MOD: TimeSpeed Mod by cantorsdust and Syndlig - Version StardewModdingAPI.Version | Description: Allows for a configurable ten minute tick length. (@ D:\Games\Stardew Valley Modded\Mods\TimeSpeed\TimeSpeed.dll)
                                        [08:46:07.776 ] Found Manifest: D:\Games\Stardew Valley Modded\Mods\TrainerMod\manifest.json
                                        [08:46:07.776 ] Created psconfigs directory @D:\Games\Stardew Valley Modded\Mods\TrainerMod\psconfigs
                                        [08:46:07.776 ] Loading Mod DLL...
                                        [08:46:07.776 ] LOADED MOD: Trainer Mod by Zoryn - Version StardewModdingAPI.Version | Description: Registers several commands to use. Most commands are trainer-like in that they offer forms of cheating. (@ D:\Games\Stardew Valley Modded\Mods\TrainerMod\TrainerMod.dll)
                                        [08:46:07.776 ] Registered command: types
                                        [08:46:07.792 ] Registered command: player_setname
                                        [08:46:07.792 ] Registered command: player_setstamina
                                        [08:46:07.792 ] Registered command: player_setmaxstamina
                                        [08:46:07.776 ] Registered command: save
                                        [08:46:07.792 ] Registered command: player_setmaxhealth
                                        [08:46:07.792 ] Registered command: player_setimmunity
                                        [08:46:07.792 ] Registered command: player_setlevel
                                        [08:46:07.792 ] Registered command: player_setspeed
                                        [08:46:07.792 ] Registered command: player_changecolour
                                        [08:46:07.776 ] Registered command: hide
                                        [08:46:07.792 ] Registered command: stop
                                        [08:46:07.792 ] Registered command: load
                                        [08:46:07.792 ] Registered command: show
                                        [08:46:07.792 ] Registered command: player_setmoney
                                        [08:46:07.792 ] Registered command: exit
                                        [08:46:07.792 ] Registered command: player_sethealth
                                        [08:46:07.792 ] Registered command: player_additem
                                        [08:46:07.792 ] Registered command: player_changestyle
                                        [08:46:07.807 ] Registered command: player_addmelee
                                        [08:46:07.807 ] Registered command: player_addring
                                        [08:46:07.807 ] Registered command: out_items
                                        [08:46:07.807 ] Registered command: out_melee
                                        [08:46:07.807 ] Registered command: out_rings
                                        [08:46:07.807 ] Registered command: newitem
                                        [08:46:07.807 ] Registered command: world_settime
                                        [08:46:07.823 ] Registered command: world_setday
                                        [08:46:07.823 ] Registered command: world_setseason
                                        [08:46:07.823 ] Registered command: world_freezetime
                                        [08:46:07.823 ] SDV Loaded Into Memory
                                        [08:46:07.823 ] LOADED 6 MODS
                                        [08:46:07.823 ] Registered command: world_setminelevel
                                        [08:46:07.823 ] Registered command: world_downminelevel
                                        [08:46:07.838 ] Initializing Console Input Thread...
                                        [08:46:07.838 ] Applying Final SDV Tweaks...
                                        [08:46:07.838 ] XNA Initialize
                                        [08:46:07.838 ] Registered command: help
                                        [08:46:08.349 ] XNA LoadContent
                                        [08:46:08.524 ] Initializing Debug Assets...
                                        [08:46:08.527 ] Game failed to start: System.MissingMethodException: Method not found: 'Int32 StardewValley.Game1.getMouseX()'.
                                        at StardewModdingAPI.Inheritance.SGame.Update(GameTime gameTime)
                                        at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
                                        at StardewModdingAPI.Program.RunGame()



                                        someone may help me?
                                         
                                          yokonzo likes this.
                                        Thread Status:
                                        Not open for further replies.

                                        Share This Page