Jump to content

Recommended Posts

Well, if you are hosting a world, then you are setting which mods are actively running for the server. Character- or Craftable- or WorldGen-mods need to be on the server, or clients can't properly use them. UI-only mods will be the clients choice (such as Always On Status, Geometric Placement, Gesture Wheel, etc).

 

But I guess you are looking to disable even the UI type of mods also? Someone way more advanced in this will need to answer, I don't have the foggiest clue how to temp-disable a client-subscribed mod. I know, my comment doesn't help, mostly this is just to understand what you're working for here.

 

Can you give an example of what you're trying to accomplish? If you don't want to reveal the full truth of your mod, can you come up with a comparable-fake example?

  • Developer

@Maris, I'm not sure what your reasons for disabling other mods are, but we do something similar when joining a server. If you have a mod enabled that is required by all clients when connecting, it is temporarily disabled.

This code exists in networking.lua in the function DownloadMods. 

KnownModIndex:UpdateModInfo()for _,mod_name in pairs(ModManager:GetEnabledModNames()) do	local modinfo = KnownModIndex:GetModInfo(mod_name)	if modinfo.all_clients_require_mod then		if server_listing_contains( server_listing.mods_description, mod_name ) then			--we found it, so leave the mod enabled			else			--this mod is required by all clients but the server doesn't have it enabled, so locally disable it temporarily.			print("Temp disabling ",mod_name)			KnownModIndex:TempDisable(mod_name)		end	endendKnownModIndex:Save()

There's actually a bug in there, "if modinfo.all_clients_require_mod then" should be "if not modinfo.client_only_mod then". Expect that to change in the next update.

Your mod could probably hook into function ServerCreationScreen:Create(), looking for the other mods you want to disable and then call KnownModIndex:TempDisable and KnownModIndex:Save.

 

That said, unless you have a really good reason why you want to disable another mod, it's probably better to structure your mod so that it doesn't conflict with others.

 

I'm not sure what your reasons for disabling other mods are

Very simple reasons. I have to disable certain client mods if it is incompatible with my "all_clients_reqiure" mod. I mean incompatible interface design in general (not the code).

Edited by Maris

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
×
  • Create New...