Jump to content

[API] Mods in Menu


Fidooop
 Share

Recommended Posts

MODS IN MENU IS BACK, BABY!
mim_logo.thumb.png.881c90973fa48fb9d8b0a69d87c1f9a8.png

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.

Spoiler

image.png.27f4ef0bec7d77af9a47437e959d6f00.png

Click it and you'll be able to view mods that are compatible with Mods in Menu!
 

Spoiler

image.thumb.png.f272e730544f16ac23f08602b21e00e8.png

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!

  1. 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.
  2. 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.
  3. 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

modclientmain.lua

Edited by Fidooop
  • Like 6
  • Thanks 5
  • GL Happy 1
Link to comment
Share on other sites

One little question, would it be possible to load the characters directly on the Item Collection TAB (the one on the image here) ? Some would maybe not like it if that makes it load 1 million character so I wonder if you could consider the idea with a toggle configuration for this, great API anyway, I'm already using it now :)

1.thumb.png.1246d98d000a86d6af296a1eb786ad13.png

(I haven't really looked how the placement of characters is managed on this screen, maybe it is automatically sorted if new characters are added ? If not, the idea is probably not really worth it but... just a little suggestion then.)

Edit : It also seems that we can't disable mods on the server mods list on servers if they are handled with MiM, is this intentional or necessary ?

Edited by ADM
  • Like 1
  • GL Happy 1
Link to comment
Share on other sites

59 minutes ago, ADM said:

One little question, would it be possible to load the characters directly on the Item Collection TAB (the one on the image here) ? Some would maybe not like it if that makes it load 1 million character so I wonder if you could consider the idea with a toggle configuration for this, great API anyway, I'm already using it now :)

1.thumb.png.1246d98d000a86d6af296a1eb786ad13.png

(I haven't really looked how the placement of characters is managed on this screen, maybe it is automatically sorted if new characters are added ? If not, the idea is probably not really worth it but... just a little suggestion then.)

Edit : It also seems that we can't disable mods on the server mods list on servers if they are handled with MiM, is this intentional or necessary ?

I intend to handle the first thing you mentioned at some point. Just still not sure how yet.

Secondly, I'll try to look into what's going on with the server screen and figure it out. It's supposed to be a separate UI and not be affected by MiM at all.

  • GL Happy 1
Link to comment
Share on other sites

8 hours ago, ADM said:

It also seems that we can't disable mods on the server mods list on servers if they are handled with MiM, is this intentional or necessary ?

Just pushed an update fixing that problem! :)

  • Thanks 1
Link to comment
Share on other sites

I added a new collection to help users find MiM-compatible mods!
https://steamcommunity.com/workshop/filedetails/?id=2417771424

 

If you'd like to do your best to help users find your mod through MiM there's 2 thing you can do.
1: Comment on the collection I made with a link to your mod, I'll add it
2: Put "Mods in Menu compatible" in your mods' description

Edited by Fidooop
Link to comment
Share on other sites

Cool mod, love it. It's been 3 years but it's finally here!
I found a little problem or issue with the mod or at least when I make some of my character mods compatible with it, most of my character mods usually have a "powerup" form, something that Wolfgang and Wormwood have normally, I've put the forms in AddModCharacter as anyone normally would but the extra forms don't show up in the wardrobe at all, they somehow show up in-game though, so I'm not really sure if that's an issue with how I implemented them in the menu or just an issue with MiM.

  • Like 1
Link to comment
Share on other sites

10 hours ago, Stormish said:

Cool mod, love it. It's been 3 years but it's finally here!
I found a little problem or issue with the mod or at least when I make some of my character mods compatible with it, most of my character mods usually have a "powerup" form, something that Wolfgang and Wormwood have normally, I've put the forms in AddModCharacter as anyone normally would but the extra forms don't show up in the wardrobe at all, they somehow show up in-game though, so I'm not really sure if that's an issue with how I implemented them in the menu or just an issue with MiM.

I'll be looking into that shortly! Thanks for your feedback, I really appreciate it :D

  • Like 1
Link to comment
Share on other sites

Also another issue I encountered with MiM

I made a character mod compatible with this mod and all works perfectly except that only this character mod is having issues and appears two times in the lobby and says it's not enabled, despite the fact I have the character mod enabled on the server screen.

Spoiler

20210310163037_1.jpg20210310164049_1.jpg

 

Edited by Stormish
Link to comment
Share on other sites

31 minutes ago, Stormish said:

Also another issue I encountered with MiM

I made a character mod compatible with this mod and all works perfectly except that only this character mod is having issues and appears two times in the lobby and says it's not enabled, despite the fact I have the character mod enabled on the server screen.

  Hide contents

20210310163037_1.jpg20210310164049_1.jpg

 

What the heck?! That was working before I uploaded! Gaaahhh. Well, I'm working on a bare bones character atm and will be able to use it to hunt and fix these bugs. So maybe later today I can push an update? Not sure yet, we'll see how tricky these bugs end up being lol

  • Like 1
Link to comment
Share on other sites

On 3/9/2021 at 8:39 AM, Stormish said:

Cool mod, love it. It's been 3 years but it's finally here!
I found a little problem or issue with the mod or at least when I make some of my character mods compatible with it, most of my character mods usually have a "powerup" form, something that Wolfgang and Wormwood have normally, I've put the forms in AddModCharacter as anyone normally would but the extra forms don't show up in the wardrobe at all, they somehow show up in-game though, so I'm not really sure if that's an issue with how I implemented them in the menu or just an issue with MiM.

Bug fixed and mod updated!

 

For everyone else wondering about the second bug Stormish found, I've been communicating with them about it to try and sleuth out what's going on because every other mod is functioning as expected. Will update MiM again if it ends up being found that it's MiM's fault! :)

  • Big Ups 1
Link to comment
Share on other sites

Hey again, I think there might a problem/bug that could require some investigating. Or maybe would there be something I can do ?
I've been recently working on adding new worldgen settings with a mod and as it is getting compatibility with MiM, well I noticed the settings just vanish while MiM is enabled (and only if the other mod is added as compatible) :

Enabled :

: Disabled

0.thumb.png.8a9db75ed61afd9d750fa755f33642c9.png0.thumb.png.9ad20e8690bea38b86686983e069d62a.png



If that can be of any help, the settings are put in modservercreationmain, which is new to the current QoL update.

Link to comment
Share on other sites

6 minutes ago, ADM said:

Hey again, I think there might a problem/bug that could require some investigating. Or maybe would there be something I can do ?
I've been recently working on adding new worldgen settings with a mod and as it is getting compatibility with MiM, well I noticed the settings just vanish while MiM is enabled (and only if the other mod is added as compatible)

I think I have an idea of how to fix this.. Could you contact me over Discord? It'll be easier for me to fix it if we can communicate back and forth.

Link to comment
Share on other sites

Hey, everyone! If the last game's update is causing your mods to crash through MiM, Cunning Fox already uploaded a temporary patch to fix the problem. And before you ask, yes, it works with MiM to become a client-mod and help out with any MiM mods crashing in the menu.
https://steamcommunity.com/sharedfiles/filedetails/?id=2423532119

As far as I am aware, Klei should be pushing a fix for this on Monday so this is only temporary.

Link to comment
Share on other sites

28 minutes ago, TrashLord said:

I apologize if this has been asked and answered before, but how would one go about creating a graphic for a mod's default head in the wardrobe?

It's the "SWAP_ICON" symbol in your characters build.

Link to comment
Share on other sites

7 hours ago, TrashLord said:

I apologize if this has been asked and answered before, but how would one go about creating a graphic for a mod's default head in the wardrobe?

What Hornet said... I think I've got a texture file somewhere though let me check.

Yep! Found it! Not the best however... I put this together a *long* time ago and you can tell the little errors in it but it still does work.411639775_chunkofwood.png.40b361bc1e8bc1f495c7f554b6923698.png

 

...Also I like your profile pic... DINGODILE FTW!!!!!!!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...