-
Notifications
You must be signed in to change notification settings - Fork 36
Using items from other mods
One of the advantages of having SMLHelper manage the addition of new items and keep track of them between game loads is that now you have a way of addressing items added by mod without having to directly reference that mod's dll.
Remember, as a courtesy, check with the mod's author and make sure they're cool with you incorporating part of their work into your mod.
See QModManager's QMod Services to check if the other mod is installed.
To be able to look for a cross-mod TechType, you'll need the internal name it was registered with.
There's a couple of ways you can get this:
- Ask the mod's author
- Check the mod's source code and look at what they used in the
TechTypeHandler.AddTechType
call. - Open the TechTypeCache.txt file and look for it. Obviously you'll need to have this mod installed yourself.
Once you have the cross-mod TechType's internal name, you'll find two methods in TechTypeHandler
to look for them.
This is a method you can if you just want to check if the player has that mod installed in the first place.
public static bool ModdedTechTypeExists([string] techtypeString);
If you don't need to actually use the item for anything but just want to enable other features when you know the player has this mod installed, this is the way to go.
You can call it like this:
bool otherModIsInstalled = TechTypeHandler.ModdedTechTypeExists("WarpCannon");
This next method is the one to call if you actually intend on using the the cross-mod TechType for anything.
public static bool TryGetModdedTechType([string] techtypeString, out [TechType] modTechType);
You'll use TechTypeHandler.TryGetModdedTechType
like any other TryGet/TryParse method in C#.
If it returns true, you're good to use the item. And if it's false, the player didn't have the mod you were looking for installed.
You can call it like this:
bool otherModIsInstalled = TechTypeHandler.TryGetModdedTechType("WarpCannon", out TechType warpCannonTechType);
Once you have an actual TechType enum instance for this cross-mod item, you can do anything with it that you would do with any other TechType.
Things you might do with another cross-mod TechType:
- Include extra crafting recipes that use this item
- Lock an extra blueprint behind this item
- Add this item as compatible with your mod's new feature
- Get creative cause it all depends on what you want to do
For more details on these methods, check the documentation in Visual Studio.
As a final remark, be aware that there is no guarantee in which order SMLHelper dependent mods are loaded.
So if two mods were installed at the same time, it may take a second game load for both mods to be visible to each other using the methods showcased here.
If there is something missing or ambiguous, please create an issue or contact us on the Subnautica Modding Discord using our tags:
- PrimeSonic:
@PrimeSonic#0667
- Metious:
@Metious#3682
Please note that some pages are under construction and the links to them will be enabled as they are completed
[Adding]
- Items/GameObjects using Asset Classes
- Asynchronous loading for ModPrefab
- [Custom Scanner Unlocks]
- Items/GameObjects to the Spawning System
- [Recipes to uncraftable items]
- [Custom Mouse Click Actions]
[Editing]
- Background Type
- Crafting Time
- Equipment Type
- Quick Slot Type
- Size in Inventory
- [Recipes for craftable items]
- Harvest Settings
- BioReactor Fuel Values
- [Scanning Count/Time]
- [Spawning (Where/How often/How many)]
[General Utilities]
- In-Game Options Menu
- Adding crafting recipes for other mods items
- Using items from other mods
- Texture/Sprite Utilities
- [Adding/Playing Audio]
- Config Files using Abstract Json Config class
- Custom Console Commands
- [Registering OnSave/OnQuit Actions]
[Language]