Changing the current mine level

Discussion in 'Mods' started by benkc, Dec 4, 2016.

  1. benkc

    benkc Space Spelunker

    I'm trying to recreate http://community.playstarbound.com/threads/smapi-skullcavesaver.111429/ with more config options. (Specifically, the ability to set your starting Skull Cave level to a percentage of your max reached, rather than saving in increments of 5.) I'm not sure if I'm going about the right way of trying to set the current floor.

    I've got things triggering in the same way (I think), but when I call:
    Game1.enterMine(false, target, "");
    from
    Events_HalfSecond
    it just re-enters the current floor, rather than floor 8 (128) like I'm telling it to. (And then, since it's still not at the target level, does that on infinite loop.)

    What's weird is if I drop in the old mod DLL as-is, it works fine. So it seems like the enterMine() call should work.

    My log is filled with spew like this, so I know I've got the math/variable right:
    [20:38:12 DEBUG BenSampleStardewMod] From level 136 and save ratio 0.5 calculated target 128.
    [20:38:12 DEBUG BenSampleStardewMod] Trying to load level 128.

    Any advice on what I'm doing wrong here and what I should be doing instead? (And any pointers on where I could find documentation to answer this type of question myself? This is my first foray into Stardew Valley modding.) :)

    I'm following this tutorial:
    http://canimod.com/guides/creating-a-smapi-mod
    Plus copying methods from cantorsdust's source from here:
    https://github.com/cantorsdust/SkullCaveSaver
    And referencing this guide on updating old SMAPI mods while doing so, as some of the stuff in the old SkullCaveSaver is deprecated now.:
    http://canimod.com/guides/updating-a-smapi-mod
    Here's a pastebin of my source code:
    http://pastebin.com/QAnjP05Q
    Thanks!
     
    • Coolwyngs

      Coolwyngs Giant Laser Beams

      I hope that you can make it work. I miss the skull cave saver. It was a good mod.
       
        benkc likes this.
      • benkc

        benkc Space Spelunker

        I haven't found any more information on enterMine(), and flipping the boolean parameter doesn't seem to change anything, but I did think of two other things to investigate:

        • In general, how do mods move the player around? I think I saw some teleport mods before, so I should try to figure out how they do that, and see if it can be applied to setting the mine floor.
        • Alternatively, how can I interact with a mine level to add ladders or holes? If I can figure this out, then I don't necessarily need to set the mine floor myself, I can instead place a down-ladder right next to the up-ladder so the user can rapidly descend up until the "save point".
         
        • benkc

          benkc Space Spelunker

          I got it working! After my attempts to auto-generate ladders didn't work, I reviewed all the source, and found that I had lost a "and not loadingNewLevel" check in one of my conditions. Adding that fixed it. Apparently enterMine() was working just fine, but I was interrupting it with another call to enterMine, repeatedly, so it never finished.

          The code is still a right mess, but if anyone would like source and/or a DLL, I'd be happy to post it. :)
           

          Share This Page