Jump to content

New Modinfo and Modsettings Changes


zarklord_klei
 Share

Recommended Posts

  • Developer

Hey modders!

There has been some improvements to modinfo and modsettings, here's how to take advantage of them:

1. New modsettings this allows you to disable two warnings/prompts for when you're developing your mods.

Spoiler

a. DisableModDisabling() run this in modsettings.lua to prevent the game from disabling all your client mods when the game crashes, only run this if you know what you are doing.

b. DisableLocalModWarning() run this to remove the warning prompt that happens when you enable an all_clients_require_mod that you're locally developing.


2. modinfo translations read this if you want to have your modinfo support multiple languages.

Spoiler

a. You can now test against the locale code in modinfo, you can find all the locale codes in scripts/languages/loc.lua, locale can be accessed under the variable "locale" in modinfo.

b. Alternatively, you can use the function ChooseTranslationTable(tbl) to get the appropriate translation, given a table like this:


local MODINFO_NAME = {
	"An English Name",
	["fr"] = "Un nom français", --in english, "A French Name"
	["de"] = "Ein deutscher Name", --in english, "A German Name"
}

calling ChooseTranslationTable(MODINFO_NAME) would return the fr string if the language was french, the de string if the language was german, and in all other cases, would return "An English Name", in summary, the first entry is the default value, and if the locale is in the table, it will return that localization of the string.


3. mod dependencies read this if your mod has dependencies on other mods.

Spoiler

 

a. Mods can now provide the game with a list of dependencies that the game will make sure are subscribed(if its a workshop mod) and enabled before launching the game(note: this list does not work on dedicated servers due to technical limitations, make sure all mod dependencies are clearly marked on the mods page so dedicated server hosters can get them also.)

b. Mods can supply dependencies in modinfo like this:


mod_dependencies = {
    {
        workshop = "workshop-XXXXXXXXX",
--this is the workshop id of the mod, this will allow the end users to get prompted to download and sub dependencies
        ["FolderName"] = false,
--string entries marked as false are for raw folder name tests, this will attempt to mark the mod stored in mods/FolderName as a dependency
        ["FancyName"] = true,
--string entries marked as true are for modname tests. this will attempt to find a mod with the name FancyName and mark it as a dependency
    },
    {--you can have multiple dependencies
        workshop = "workshop-XXXXXXX",
    	--you can't have multiple workshop id's
        ["Foo"] = false, --but you can have multiple raw folder names
        ["Bar"] = false,
        ["FooBar"] = true, --and multiple fancy names
        ["BarFoo"] = true,
    },
    {	
       	--only have a workshop dependency
        workshop = "workshop-XXXXXXXXXX",
    },
    {
        --and even have a mod that has no workshop version as a dependency
        ["TestMod"] = false,
        ["Test Mod Official"] = true,
    },
}

c. If the mod with these dependencies is a workshop mod, the workshop version will be prioritized, if its a local version, a local version will be prioritized, if some version of the mod is already enabled(local or workshop), that version will be used, if no mod is found, your mod will fail to load.
d. If you have used the previous external "librarymanager" or "moddependencymanager" files, those will automatically be intercepted by the game, and will still work, just in a more limited function, this was to prevent lots of crashes, please update to the new format as soon as you can.

 

  • Like 11
  • Thanks 6
  • Health 1
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...