Modding Help Replacing Stable Asset

Discussion in 'Mods' started by jdvicks94, Jun 27, 2018.

  1. jdvicks94

    jdvicks94 Intergalactic Tourist

    So I am using smAPI to replace a bunch of textures with my own. I have successfully done it with the IAssetLoader class, using canLoad and Load. However, the Stable does not load when I load up a game, and I believe when I step out of the farmhouse, then it tries to load the stable, but then my mod crashes and I get an error:

    ....Using default texture.....make sure to load asset before draw loop

    My code:

    Public bool CanLoad<T>(IAssetInfo asset){
    string name = asset.AssetName as string;
    switch(name){
    case: “Buildings\\Stable”: return true;
    }
    }

    Public T Load<T>(IAssetInfo asset){
    string name = asset.AssetName as string;
    switch(name){
    case “Buildings\\Stable”: return this.Helper.Content.Load<T>(“assets/Stable.png”, ContentSource.ModFolder);
    }
    }


    The reason why I am using the Switch statement is because I am change 20+ assets. I just put the Stable case in to show. But all the other cases work fine, I have dogs, goats, pigs, and even the entire bathhouse replaced through the cases.

    I have looked into the GraphicEvents.OnPreRenderEvent. Which I think is the event for doing something before the draw loop mentioned in my error. I just have no idea how to load my Stable.png before this draw loop happens.

    Thanks so much for the help people!!! :D

    Ps- I know that by casting the asset name to a string is stupid and thus will only work on windows as Linux uses forward slashes and not backward slashes, don’t bother me about it.

    Lots of Love,

    Jesse :D
     
    • paradigmnomad

      paradigmnomad Scruffy Nerf-Herder

      Why don't use just use ContentPatcher to replace the pre-existing images?
       
      • jdvicks94

        jdvicks94 Intergalactic Tourist

        Hey thanks,

        I am a giant spoon and do not know where to find the Content Patcher. I know it is on nexus mods but I do not want to get an account.

        I am also editing with CanEdit class. So I would like to figure out the draw loop because its one of the last things I need to do D:

        Thanks for the suggestion though. And if you know where I can get the Content Patcher other than nexus mods, then it shall be my last resort!

        I don't know if this helps at all (probably doesn't)
        [​IMG]
         

          Attached Files:

          Last edited: Jun 28, 2018
        • farmerjack

          farmerjack Void-Bound Voyager

          Hey there Jesse, while I have extremely little coding experience, I’ve been lurking here in these forums for quite some time now.

          I’ve found that the Stardew modding community is very open, welcoming, and generally very understanding; while I imagine that someone here might have the ability to help you from a technical aspect, I’ve learned in my very, very limited programming knowledge that community, no matter what community it is, is where it’s at. What I mean by this is that I know that coders often use one another and one another’s resources in order to learn more and perfect their own work while their skills develop. To this end, I would suggest downloading the aforementioned Content Patcher mod and opening it up to see how it works with SMAPI, and tweaking your own work along the same lines. Check out some of the official threads here on this forum for mods, including Content Patcher; you’ll find that many of them are open source with their full contents on github.

          As for nexus, I can’t speak on anyone else’s behalf, but the accounts are free and I’ve never had a problem with anything from there that wasn’t user error.
           

          Share This Page