Mutator Helper
A simple mod which will help you add new mutators to the game. It helps you add new mutators with a simple one line call.
For updates you need SuperBLT.
If you are not a developer, you can skip this part.
Spoiler!
MyMutator = MyMutator or class(BaseMutator)
...
MyMutator.texture = -- For custom texture (required dimensions: 128x128)
{ -- If "custom" is set to true, path is following Mutator mod path
path = "guis/textures/MyMutatorTexture", -- Write here your custom texture here or use already one in the game
custom = true -- If your texture is custom (eg. new), set this to true
x = 0, -- If you use a texture from the game, make sure you also set these 4 variables
y = 0, -- They are not used, if "custom" is set to true
h = 0,
w = 0
}
MyMutator.localization = -- Useful if you are adding 2 or more mutators in one mod. Use this in your every mutator if you want differenciate mutator's language file.
{
path = "MyMutator" -- ModPath .. "MyMutator/"
}
function MyMutator:setup() -- Optional
end
function MyMutator:init_finalize() -- Called by GameSetup; Optional
end
function MyMutator:init_finalize_setup() -- Called by Setup; Optional
end
if not MutatorHelper then return end
MutatorHelper:AddMutator(MyMutator, ModPath)
Your new mutator may have a "setup" function and must inherit from the "BaseMutator" class. When you are done, don't forget to call MutatorHelper:AddMutator function to add new mutator to the game. The "MyMutator" parametr adds your mutator to the game and "ModPath" parametr adds translation to your new mutator. Both parameters are needed! Otherwise your new mutator will not show in-game and will not work.
To add translation to your mutator, create a "loc" folder in your mutator folder and name your translations with full names (eg. english, french, etc...). Those files must have a "json" extension, otherwise your translation will not be loaded and your mutator will show error strings.
Supported languages are:
English
French
German
Italian
Russian
Spanish
Dutch
Swedish
Thai
Simplified Chinese (name the file as "schinese.json")
When you have everything from the above, make sure you hook your new mutator to "lib/mutators/basemutator", otherwise it will not work.
Version r2 added support for "init_finalize" function. This function is called when everything is almost ready. To use it in your new Mutators, create "init_finalize" function (called by GameSetup) or "init_finalize_setup" function (called by Setup). Nothing is passed to these functions. This function is optional and will not crash your game, if your Mutator doesn't have it declared.
Version r5 added support for custom categories.
if not MutatorHelper then return end -- Adds custom category to the Mutator screen
MutatorHelper:AddCategory("crime_spree", { string = "menu_gamemode_spree", path = ModPath })
To add a new category, simply call AddCategory function. First parametr describes your category (don't forget this category identifier to your Mutator to separate them from others), second parametr is used for language file. Second parameter must be a table and the table must contains one of these variables:
string - use string from the game
path - load your category name from a file
"string" variable always takes precedence before path. You can't use both. If you want to use "path" variable, it must hold "ModPath". Don't forget to place your language files to the "loc" folder once done. Supported languages are above.
If you are overwriting values in a existing mutator, you don't need this mod! This mod is intended to add new mutators to the game, not change their behavior.
I promise I'll add templates, someday.
Please submit issues/new features here
Comments