Tool SMAPI: Stardew Modding API

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

  1. SasuraUchiha

    SasuraUchiha Scruffy Nerf-Herder

    Yeah, I know. I renamed it to manifest.json, but the name is still manifest.json.txt... It seems I can't simply change .txt to .json... Don't know why...

    Edit: nvm, just got it... Still I need to create the file with Notepad++, so that I can make a json-file instead of a txt-file.
     
    • ClxS

      ClxS Scruffy Nerf-Herder

      Ah sorry I forgot to mention that. For others: You need to have the Show Extensions options on in Windows Explorer to just change the extension like that. Or, when you're saving with something like Notepad, select 'All Files' on the 'Save as type' dropdown to stop it automatically adding the .txt.
       
      • ClxS

        ClxS Scruffy Nerf-Herder

        FutureVersion Preview

        Here's a feature preview from the in-progress rewrite. This is not available in SMAPI yet.
        Cancellable events work now. Here's an example of it when you cancel the OnBeforePlayerTakesDamage event. Like you can see from the code snippet below, it's pretty Storm-like.

        Code:

        Code:
        namespace ImmortalMod
        {
            class Immortal : SMAPI.Mod
            {
                public override void Entry()
                {
                    Log.IsVerbose = true;
                    SMAPI.Events.PlayerEvents.OnBeforePlayerTakesDamage += PlayerEvents_OnBeforePlayerTakesDamage;
                }
        
                private void PlayerEvents_OnBeforePlayerTakesDamage(object sender, EventArgsOnBeforePlayerTakesDamage e)
                {
                    Log.Info("PlayerEvents_OnBeforePlayerTakesDamage");
                    e.Cancel = true;
                }
            }
        }
        


        Image (6mb GIF):

        CancellableEvent.gif


        Also added it automatic unloading of mods. This means that if a mod throws an error in an event handler (something that'd crash the game in SMAPI and Storm I think), it'll be captured and the mod will be disabled with a big red warning in the log. (All of it's events will be unregistered.)
         
          ThatNorthernMonkey likes this.
        • OrSpeeder

          OrSpeeder Phantasmal Quasar

          Can you share that work in progress code with some modders, so that it launches better? (ie: launches with obvious to modders but not obvious to you suggestions and bugfixes implemented for example, also launches with "launch mods" too, so people have a reason to use it, in case it isn't backwards compatible).
           
          • ClxS

            ClxS Scruffy Nerf-Herder

            I will closer to release since it's still quite a way away. Since it involves a complete rewrite I do not want people to start targeting mods against it or to start writing their mods against features which will definitely be changed by release (That's one of the pains Storm had :)), and there's the chance that it'll suffer from design by committee if it receives public input at this early stage.
            It will be compatible with the latest version of SMAPI mods when it releases, so I suggest people just keep targeting those for now.
             
            • Dilwoah

              Dilwoah Void-Bound Voyager

              So is this replacing STORM? I haven't been keeping up with the modding community for a bit but last I knew SMAPI was dropped so Storm would be the only one, but now when I come back I see all these mods for smapi again. Which one should I choose? Is one going to outlast the other?
               
              • ClxS

                ClxS Scruffy Nerf-Herder

                After Zoryn left SMAPI to work on Storm, I decided to continue working on SMAPI - mostly to keep it compatible with future versions of Stardew but also slowly add new features. I was worried with a few of the design decisions of Storm making it not a good replacement.

                Well, some people were dissatisfied with the direction and progress of Storm, including Zoryn who has come back to work on SMAPI. Shortly after she came back, two of the main developers of Storm have left the project (Dem and MDBell), and I also think the other developer, Handsomematt, has had his write permissions to it removed. To me that means Storm is dead unless someone were to fork it and continue development.

                SMAPI is going to outlast Storm now. I expect SMAPI to be consumed by a more mature API in the future.
                 
                • Dilwoah

                  Dilwoah Void-Bound Voyager

                  Alright, so now I gotta switch BACK over to smapi xD MAKE UP YOUR MIND PEOPLE! jk ily all
                   
                  • Kit Ballard

                    Kit Ballard Tentacle Wrangler

                    I haven't updated yet, and the convert old files thing is a pain, but I personally agree with the new file system layout. It keeps the mod folder clean and orderly, and all of the related mod's files and folders are grouped into one place, making "uninstalling" easy. Good work.
                     
                      Last edited: Mar 25, 2016
                      07ggn and Superior_s like this.
                    • aracco

                      aracco Void-Bound Voyager

                      What is the base directory from which SMAPI loads paths? I'm not all that familiar with C#, so I'm not sure how to check. I'm trying to load a resource from the Content folder.

                      Edit: never mind, it looks like Game1.content.Load handles it automatically.
                       
                        Last edited: Mar 25, 2016
                      • Quinloki

                        Quinloki Void-Bound Voyager

                        First time modder (just getting that out of the way now) been using IDED's videos trying to get things working, but I keep running into an issue.

                        SMAPI opens, runs a single line, then says something about path error and press any key to close. Now, I'm rather stuck with Windows 10 and I have no clue how to fix it - I'm assuming the issue is because of Win10, since I've gone over the installation process a dozen times so far, restarted, tried alternative directories, and even snagged a Mod Manager (again, thanks to IDED).

                        I appreciate any assistance, and once I get home (currently on lunch at work) I can provide any screen caps if needed.
                         
                        • ClxS

                          ClxS Scruffy Nerf-Herder

                          I'm on Windows 10 myself both here and at work so it should work.
                          I'll have to see the error to take a guess at what it might be. :)
                           
                          • fdg21

                            fdg21 Subatomic Cosmonaut

                            would love to have a insta grow button for trees and plants added to smapi, even a increase relation or meet everyone button, i find that ind of annoying that i cant get the community center unless i meet everyone....LOVE IT!!!
                             
                            • Quinloki

                              Quinloki Void-Bound Voyager

                              After restarting (and being at work all day) I retried it and go this

                              http://imgur.com/IJ17iGH

                              And the good news is I /still/ don't know what to do ^^;
                               
                              • Yunix

                                Yunix Big Damn Hero

                                Ich hab zwar keine ahnung von dem ganzen aber es sieht aus als würde er ".NET Framework 4.0" nicht finden.
                                Falls du es noch nicht installiert hast mach das mal, ansonsten installier es mal neu... zumindest würde ich das machen.

                                EDIT: Sorry, i should not write stuff when i just woke up...
                                Translation of my post:
                                I dont have alot of knowledge about stuff like this but it seems like he cant find ".NET Framework 4.0". Better go install it, or if its already reinstall it. That's atleast what i would do...
                                 
                                  Last edited: Mar 26, 2016
                                • ClxS

                                  ClxS Scruffy Nerf-Herder

                                  A couple of other people have had that same problem with SMAPI and Storm. I'm not too sure really since I thought installing the game through Steam would automatically install .NET 4.0.
                                  My guess would be to try reinstalling .NET 4.0 here: https://www.microsoft.com/en-gb/download/details.aspx?id=17851
                                   
                                  • iceburg 333

                                    iceburg 333 Void-Bound Voyager

                                    Hi All!

                                    I'm very excited to get into modding Stardew Valley and my TL;DNR is: Are their any good SMAPI tutorials out there?

                                    More Background:

                                    I am a Java Developer with basic work in C#.

                                    I've downloaded and installed Storm and SMAPI, setup Storm for modding and didn't have access to a class I wanted to use. Then I read people are moving back to SMAPI and that through it you can touch/ override game source.

                                    I've decompiled the Stardew Source code. I'd like to override the ShippingMenu class to add an additional method (I want to record what has been shipped).

                                    I have my overriden class, and I've read that SMAPI allows you to override base classes, but I'm not sure how to set up the SMAPI for dev (I've added it to my references?) and how to hook in so it will use my class instead of ShippingMenu.

                                    Are there any tutorials I could take a look at for SMAPI Dev setup?

                                    Thanks all, I've been loving Stardew, and the fact that the future looks bright for modding it has me ecstatic.

                                    Keep up the great work!

                                    Ice
                                     

                                      Attached Files:

                                      Drogean likes this.
                                    • Quinloki

                                      Quinloki Void-Bound Voyager

                                      It says I already have 4.5 and won't install 4.0 - and after some trying, getting 4.5 out of there to install 4.0 seems almost impossible @_@
                                       
                                      • McmcKun

                                        McmcKun Seal Broken

                                        When i paste in the code and edit it and start the ModdingAPI, it doesnt seem to find it. The only file it finds is the TrainerMod.
                                         
                                        • ClxS

                                          ClxS Scruffy Nerf-Herder

                                          Hey Iceberg + McmcKun, Zoryn wrote a tutorial here for how to create your first mod: https://github.com/ClxS/SMAPI/wiki/[Tutorial]-Creating-a-Mod :)
                                          She also has a bunch of SMAPI mods here that could be used as a reference on how to do some stuff: https://github.com/Zoryn4163/SMAPI-Mods

                                          iceberg for your idea what might work in SMAPI is doing similar to what Zoryn does on some of her mods (like this https://github.com/Zoryn4163/SMAPI-Mods/blob/master/JunimoDepositAnywhere/JunimoDepositAnywhere.cs). In the update tick, she checks whether Game1.activeClickableMenu menu is of type T, and if it is, do something. In your case check if it's the ShippingMenu and if it is replace it with your overrided type.

                                          Unfortunately the current version of SMAPI doesn't use injected hooks yet, so you'll have to directly overwrite the activeClickableMenu for now. Forcing the base methods to be virtual is a feature already included in the upcoming rewrite which adds many additional features, but isn't currently available in this version.
                                           

                                          Share This Page