Modding Help standalone mod that adds recipes only if another specific mod is present

Discussion in 'Starbound Modding' started by rare_candy_bracelet, Oct 16, 2017.

  1. rare_candy_bracelet

    rare_candy_bracelet Existential Complex

    What I mean is, I need to know if it's possible to have a mod that works by itself, but if a certain mod is present, will add in recipes based on that other mod's items that players who haven't downloaded won't have access to. I know the line "includes:" makes a mod load after another one if that mod is present, but I want to know if just having the recipes in the mod without the other mod present will crash the game. does that make sense? I need to know for... reasons.
     
  2. bk3k

    bk3k Oxygen Tank

    It doesn't crash the game when recipes contain references to (often just misspelled) non-existent items/objects , but you get lots of errors in the log. Not fatal, but annoying when tracking down other errors.

    The real workaround is LUA dependent, and is one of my current projects. The objects dynamically build a recipe list to pass to the crafting interface. Thus it doesn't use actual .recipe files anymore. These stations each have a .config file full of recipes(stuff that doesn't require external mods), and more can be appended into it depending upon detecting other supported mods. It would be possible to append more when other mods are absent instead - alternate (less preferred) recipes for when the mod is alone.

    Although not currently part of my plans, it would be possible to alter a recipe's input or output based off of any conditional statement that scripts can access/measure. Such as building things cheaper on higher threat planets, or from upgraded stations. I different little project I made a while back can give you better weapons when used on a higher tier planet.

    edit:
    Well another workaround is having external patch mods that tie two other mods together better in this way - that's what most people do. I strongly prefer baking in support within the main mod.
     
    rare_candy_bracelet likes this.
  3. GonDragon

    GonDragon Pangalactic Porcupine

    There is a good example of that in the Frogss Furniture, where the recipes are automatically generated with LUA. If you want to have more intricated recipes than just pixels, just save those recipes in a small "datbase" inside the .object file, or even in an independent .config file. Also, you can use root.recipesForItem(String itemName) to use any other already existent recipe.

    You can easily parse a JSON structure in an external file (if you want to have your "recipes" separated from your .object) with the lua function: root.assetJson( String AssethPath )

    About check if the other mod is installed, I don't know but using the above function to check the existence of the object that you want to create a recipe could work.
     
    rare_candy_bracelet likes this.
  4. bk3k

    bk3k Oxygen Tank

    Actually finding if a mod is installed via LUA is generally pretty easy. Look for any JSON file you know they changed. Load that file with root.assetJson and then see if their specific alteration has been applied.

    You can do something similar when patching files courtesy of patching and using test conditions.
     

Share This Page