Tool Stardew Modding API

Discussion in 'Mods' started by Zoryn4163, Feb 28, 2016.

  1. redteam

    redteam Scruffy Nerf-Herder

    Threw this into a DLL to test out Zoryn's nice setup. Throw it in %appdata%/StardewValley/Mods. This should add all crafting and cooking recipes to your character with the new command `player_addrecipes`.
     
    • cantorsdust

      cantorsdust Existential Complex

      I suppose it wouldn't hurt to have the commands in a separate DLL module to show people how to use one, but I don't see the harm in having additional commands. If you don't want to use the commands, don't use the commands.
       
      • boomer678

        boomer678 Void-Bound Voyager

        I'm trying to use your API with my modified assembly from https://github.com/kevinmurphy678/Stardew_Injector, to possibly create a way to override methods within the API. I keep getting this error though and I'm not sure whats going on. Im just replacing StardewAssembly with my modified version
        Edit: It seems to be caused by the modified assembly, not really sure what can be done about this
        [​IMG]
         
          Last edited: Feb 29, 2016
          Drogean likes this.
        • Zoryn4163

          Zoryn4163 Big Damn Hero

          Alright I'll think about that then. We're talking kilobytes of extra data though, I really see no reason to not keep them together. The file is currently a measly 35KB

          This is because my API is trying to load the native stardew assembly, and while they have the same name, C# knows they aren't the same. Is there no way to hook directly as a mod inheriting from my assembly to get what you need done?
          I took at a look at your injector github source; from inheriting as a mod, you can grab Program.StardewAssembly to get its native assembly, and then make your calls as needed, can't you?
          If it helps at all, there are these 3 fields in Program.cs that may be of use to you:
          StardewAssembly = AppDomain.CurrentDomain.GetAssemblies().First(x => x.GetName().Name.Equals("Stardew Valley"));
          StardewProgramType = StardewAssembly.GetType("StardewValley.Program", true);
          StardewGameInfo = StardewProgramType.GetField("gamePtr");
           
            Last edited: Feb 29, 2016
          • boomer678

            boomer678 Void-Bound Voyager

            Yeah I'm not sure. I've never done anything like this so I don't know how a lot of things work. There's probably a better way to do it. Do you know if there is a plan for an official modding api?
             
            • Zoryn4163

              Zoryn4163 Big Damn Hero

              I don't, however I currently am working on overriding code and implementing custom events and etc. I'll see how hard it is to override the movement method from a mod and hopefully it'll be much easier than all the stuff you had.
               
              • boomer678

                boomer678 Void-Bound Voyager

                Alright, cool. Let me know if you make any progress! I'll be watching this thread and the repo
                 
                • animandan

                  animandan Void-Bound Voyager

                  By "Custom Events" do you mean adding new stuff rather than just messing with what's already in the game? In any case, heck yes, great work so far!
                   
                  • Zoryn4163

                    Zoryn4163 Big Damn Hero

                    "Custom Events" refers to being able to make calls when things occur. Like when you save your game. Wake up. Go fishing. Press a keyboard button. Etc etc. Custom Content is also on my agenda. Currently I'm working on modifying the fishing minigame as a test.
                    Edit: The fishing minigame can get really, really hard.
                    Edit2: Also really really silly. See OP for GIFS
                     
                      Last edited: Feb 29, 2016
                    • cantorsdust

                      cantorsdust Existential Complex

                      I have something you might be able to help with, Zoryn. I was working on adding items, as you saw, and I get a crash when expanding the size of Content\Maps\springobjects.xnb. The PNG inside has dimensions 384 x 524 (16x16 sprites). Trying to add a new row and making the dimensions 384 x 544 crashed it with the following log.

                      [​IMG]

                      Is there anything you can do via API to suppress this? I don't know if that would allow the file to load properly--probably not--but it's a start. It strikes me as odd, though. Presumably ConcernedApe added items continually throughout development and had to change the PNG dimensions several times. Why would he hardcode how big it needs to be?
                       
                      • Zoryn4163

                        Zoryn4163 Big Damn Hero

                        Can I have whatever files cause the crash? Personally, I don't know how to expand the contents of an XNB file, and haven't looked into precompiled edits yet. My goal with the API is to be able to register new items in realtime, but I have no issue trying to fix this error if you provide the cause of the crash.
                         
                        • cantorsdust

                          cantorsdust Existential Complex

                          Attached Files:

                        • Zoryn4163

                          Zoryn4163 Big Damn Hero

                          I'm unsure if I somehow fixed the issue with the current version I'm testing with, but I'm unable to crash the game with those files. You can get the version I just used from dowloading the current repo off of github and using the EXE in the Releases folder.
                           
                          • cantorsdust

                            cantorsdust Existential Complex

                            Very odd. Did you replace Content\springobjects.xnb or Content\Maps\springobject.xnb. The mod requires the second one, the one in Conent\Maps. I just went back and recreated the crash using the files I sent you, so I feel confident that those are the right ones.
                             
                            • Zoryn4163

                              Zoryn4163 Big Damn Hero

                              Alright I didn't realize it was Content\Maps, I will try again in a bit, however I currently have the game loading new items in realtime from code, so...
                              Edit: [​IMG]
                               
                              • cantorsdust

                                cantorsdust Existential Complex

                                Well that will be a hell of a lot easier than the annoying mess I went through. That's great news.
                                 
                                • Zoryn4163

                                  Zoryn4163 Big Damn Hero

                                  I did it.
                                  Edit: The texture shown is a PNG in the mods\content folder in appdata. This directory may move to the install location of stardew at some point but for now it's right next to savedata and errorlogs
                                  [​IMG]
                                   
                                  • jkkr

                                    jkkr Void-Bound Voyager

                                    I have to say this is great work thus far for me ^^ ( downloaded it yest.)
                                     
                                    • animandan

                                      animandan Void-Bound Voyager

                                      Oh snap, awesome.
                                       
                                      • cantorsdust

                                        cantorsdust Existential Complex

                                        Something I just realized from the picture--that PNG is definitely not 16 x 16 pixels. Can you put in textures of arbitrary size?

                                        Stardew HD mod incoming! (Please no one do this because it would look terrible)
                                         

                                        Share This Page