Repository navigation
Adding the GMM to your game
- Download the most recent release of the GMM from https://github.com/Ategon/Godot-Mod-Manager/releases
- Add the folder into the addons folder in your project (if there is none then make one)
- Add the Gmm.tscn scene as an autoload (Go to Project->Project Settings->Autoload->The file icon beside the path input box->Navigate to Gmm.tscn and double click on it->Click the add button to the right of the node name input box)
⭐ The mod loader will now function in your game. Everything else is now optional features to give people modding your game better access to changing things
The console is a window that can be pulled up while the game is running to run various commands (ex. the set_data command sets the value of a variable as if a mod had changed it (but it only changes for that session).
The commands available can also be extended by you or the modders to give commands specific to your game or to the mods.
To enable the console just add a new input action called console and assign it a key (Go to Project->Project Settings->Input Map->Type console into the add new action box->Click Add->Click the plus beside the new console action that was created->Set the key you want to open the console)
The console will now be able to be opened in game by using that key. To see a list of all available commands type help in the console
Note this is only relevant if you have enabled the console as shown above.
You can create commands to allow players and modders to change things while a game is running (ex. enabling or disabling a speedrun timer, teleporting to a certain room, etc.)
To create commands first make a folder in your project called parts. Inside this folder make a file called commands.gd and open it up to be edited. Delete all of the current contents of the file and at the top of the file write extends Resource. Inside of this file you can define functions which will correspond to the commands ran in the console.
- The name of the function will be the name of the command
- The arguments of the function will be arguments passed into the command (space delimited in the console). You can show what type the arguments should be to only accept values of that type that were entered in and you can set default values if its not necessary for that argument to be given.
- The contents of the function will be ran when somebody uses the command.
- The return value of the function must be a string corresponding to the output that gets sent to the console after the command was ran. This supports BBCode if you want to color certain words or make things fancy. You can have returns multiple times in the function if theres different possible console outputs or if you want to output things such as errors. If you don't want to output anything you can return an empty string
- At the end of your function arguments you can define an argument called help and assign it a default value corresponding to help text for the command (Will be outputted when someone runs the help command and then the command name as an argument)
- At the end of your function arguments you can define an argument called alias and assign it a default value of either an array of strings or a string for alternative command names that someone can enter into the console instead of your main one
Example:
extends Resource
func echo(text: String, help = "Prints out the given text to the console", alias = ["e"]):
return text> echo test
test
> e aasfasoifnaisf
aasfasoifnaisf
> echo
Not enough arguments! 1 argument expected
> help echo
echo [text: String]
Prints out the given text to the console
Alias: e
In your game you can define variables in txt files in a certain way to be read in by the manager, and then modders can then change those variables to easily allow tweaking the behaviour of things. (Also images, scripts)
To start first make a folder called parts in your project. In this folder you can make other folders to make categories (and then nested folders in those, etc.). You can make a txt file anywhere and call it whatever you want. The name will become a category to then access the variables inside of it.
To create variables in a txt file just make key value pairs separated by a colon and then a space. Each variable is on a new line
movement-speed: 400
jump-height: 200
To make comments just write a string on a new line without any colon in it and without any indenting. Note: it is recommended to lead comments with a symbol such as % to improve readability.
To make arrays of values just do the name of the array followed by opening and closing square brackets. Every element of the array must then be on new lines indented one tab out (these can have a colon to make it a key value pair, or a regular value)
%% Attributes
movement-speed: 400
jump-height: 200
colors[]
blue
red
green
orange
Inside your game you can then read these values through the data attribute in the Gmm autoload. For example if you wanted to get the movement-speed from a file called character1.txt
var movement_speed = Gmm.data.character1["movement-speed"]
If the character1.txt file was in a folder called characters and the characters folder was in a folder called values
var movement_speed = Gmm.data.values.characters.character1["movement-speed"]