MODS IN MENU IS BACK, BABY!
And this time, it's here to stay!
No more hand-holding
No more spammy tables in the modinfo
No more crashing with every Klei update
Now fully open with limitless capabilities
Fully loads server mods on the clientside
Able to access a mod's configuration
Allows for Postinits, Prefabs, and Assets to be added
Put characters in the main menu
Insanely easy and user-friendly
How does it work? I'll tell you!
A brand new tab will appear in your mods menu.
Click it and you'll be able to view mods that are compatible with Mods in Menu!
And that's it! Click apply and you will be able to see changes that mod wants to make to the main menu!
Ok, but how can I make my mod compatible?
Simply add a modclientmain.lua file to your mod.
Treat this modclientmain as if it were a second modmain that only loads clientside. (because it is)
And that's it! Your mod is ready to access the clientside!
Okay but in all seriousness though, there's a few important things I need to note and go over.
Firstly, an explanation of what exactly is going on here to help those newer to code understand.
Your modmain.lua file is essentially the starting point of your mod when it is loaded. It brings in assets, prefabs, and game changes, all starting from that single file. The new modclientmain.lua is essentially the SAME EXACT THING with all the SAME EXACT CAPABILITIES. However, it is loaded on the clientside via Mods in Menu!
"Okay but why would I need that? I could just set my mod to be clientside!", I hear you audibly questioning from your brain. And I have an answer! Making your mod clientside will prevent it from being enabled serverside! This is bad for a modded character for example. This feature is mainly there for server-only mods to reach their characters and items into the main menu for users to enjoy more features!
Now I've gotta cover some basic restrictions and changes that everyone should pay attention to.
First, your mod's priority. It is very important that you do not reach this priority number (-2147483647) with your server mod as Mods in Menu MUST load after all server mods to prevent major issues. If you need your server mod to load on the backend then do -2147483646 instead. For those interested, all mods loaded by MiM will then load AFTER MiM using the normal priority rules.
Next thing to note, is that when working with your modclientmain your goal is to use the absolute minimum code/strings/assets possible! The entire reason Klei originally moved server mods to not enable on the clientside is because they wanted to cut down on load times. Keep this in mind when working with your modclientmain and only require assets/code that is absolutely necessary for your character or changes to appear in the main menu as intended!
Depending on your programming experience, there's a multitude of ways that you can use your modclientmain!
Handle your modmain and modclientmain files completely separately. This is the easiest for those not too familiar with code but takes more time and effort to upkeep.
Have both your modmain and modclientmain require a common file that will register all assets/prefabs/strings/etc that would otherwise be shared between both files. This makes upkeep nice and easy and it cuts out all repeating code.
DO NOT DO THIS UNLESS YOU ABSOLUTELY KNOW WHAT YOU ARE DOING. Calling modimport("modmain") will load your modmain file, leaving the modclientmain practically untouched and load your full mod as intended serverside. This will be the optimally efficient way to handle your mod but things can go south quickly if you don't do it right, it can be dangerous.
There are a couple IF checks to help out with the 2nd and 3rd methods to ensure you don't load serverside things on the client!
--This variable gets added to your modding environment by Mods in Menu
--Use this check to see if your file is being run on a server or by Mods in Menu
if is_mim_enabled then
--This is a check I found while building this API actually and it can prove to be quite helpful for mods enabled on both client and server
--The gamemode will always return an empty string if you're in the main menu and not in-game
if TheNet:GetServerGameMode() == "" then
And that's all anyone needs to know really! Attached to this post will be a modclientmain file I whipped up as an example using the Whemy The Witch mod under the first handling method.
IF THERE ARE ANY QUESTIONS, PLEASE FEEL FREE TO ASK HERE!
SPECIAL THANKS TO:
Erik for drawing the mod icon image (isn't it awesome looking?) Hornet for encouraging me and letting me use Hamlet characters as guineapigs Von for letting me use Whemy as a guineapig
Get the API on Steam: https://steamcommunity.com/sharedfiles/filedetails/?id=2415978456