Skip to content
cech12 edited this page May 21, 2019 · 4 revisions

Create a Mod

The following steps have to be done to develop a mod for the DigglesModManager

  1. Install DigglesModManager
  2. Create a new directory in the Mods directory. You can choose a name for it.
  3. All directories and files inside of it will be copied into the game directory or are used for changes of the original game files.
  4. Create a "config.json" file.

Mod Directory Layout

All files in the directory of your mod are copied into the game directory or are used for changes of game files. Example: You put the file "test.txt" into the root of your mod directory, it will be copied in the root game directory (where the diggles.exe lies)

The following files are ignored in the root:

  • config.json
  • LICENSE
  • README.md

The following directories are ignored in every directory:

  • .git

config.json

The structure of the "config.json" file is a JSON object. Here is the minimal example. All the values are needed to show your mod inside the DigglesModManager.

{
	"version" : "1.0",
	"author" : "YourName",

	"name" :  {
		"en" : "ModName"
	},
	"description" : {
		"en" : "This is the description of your mod."
	},
	
	"links" : {
		"download" : "https://github.com/.../releases",
		"wiki" : "https://github.com/.../wiki"
	}
}

The JSON objects "name" and "description" can be extended with other translations, but the english translation is required. Other languages can be "de", "es", "fr", "it", "nl", "pl" and "ru".

You can also add mod settings inside of the "config.json". There are different types of variables you can define. Every variable needs an ID, a name, a description, a default value and a type (string, int, bool, select). You can find examples below. You can define more than one variable inside of the settings array.

String variable

Here you can ask for a string value.

"settings" : [
	{
		"id" : "NAME",
		"type" : "string",
		"default" : "Grumpy Item",
		"name" :  {
			"en" : "Item name",
			"de" : "Item-Name"
		},
		"description" : {
			"en" : "Name of new Item",
			"de" : "Name des neuen Items"
		}
	}
]

Int variable

Here you can ask for an integer value. You can define a min and max value (not required).

"settings" : [
	{
		"id" : "ITEMS_PER_SLOT",
		"type" : "int",
		"default" : 9,
		"min" : 1,
		"max" : 20,
		"name" :  {
			"en" : "Items per slot",
			"de" : "Items pro Slot"
		},
		"description" : {
			"en" : "Count of items per storage slot",
			"de" : "Anzahl der Items pro Lager-Slot"
		}
	}
]

Bool variable

Here you can ask for a bool value. The user will see it as a checkbox.

"settings" : [
	{
		"id" : "ADD_STORE_ROW",
		"type" : "bool",
		"default" : true,
		"name" :  {
			"en" : "Add store row",
			"de" : "Regal hinzufügen"
		},
		"description" : {
			"en" : "Add upper store row",
			"de" : "Oberes Lagerregal hinzufügen"
		}
	}
]

Select variable

In a Select variable, you can predefine the allowed values and can give them other names. So the user can choose the value via a drop down selection. Here is an example:

"settings" : [
	{
		"id" : "CLAN",
		"type" : "select",
		"default" : 0,
		"name" :  {
			"en" : "Clan",
			"de" : "Clan"
		},
		"description" : {
			"en" : "Clan that you want to play in campaign.",
			"de" : "Clan, den du in der Kampagne spielen möchtest."
		},
		"possibleValues" : [
			{
				"value" : 0,
				"name" : {
					"en" : "Diggles",
					"de" : "Wiggles"
				}
			},
			{
				"value" : 1,
				"name" : {
					"en" : "Peacer",
					"de" : "Peacer"
				}
			},
			{
				"value" : 2,
				"name" : {
					"en" : "Knockers",
					"de" : "Knockers"
				}
			},
			{
				"value" : 3,
				"name" : {
					"en" : "Brains",
					"de" : "Brains"
				}
			},
			{
				"value" : 4,
				"name" : {
					"en" : "Vampyres",
					"de" : "Vampyres"
				}
			}
		]
	}
]

Directory Handling

Since DigglesModManager v1.2 there is also the possibility to define directories as optional or define more than one Data directory. You can connect these directories to variables or installed mods. The path is relative to the root directory. Here is an example of the HD mod:

"directories" : [
	{
		"type" : "data",
		"path" : "Data_de",
		"condition" : {
			"type" : "variable",
			"id" : "LANGUAGE",
			"value" : "de"
		}
	},
	{
		"type" : "data",
		"path" : "Data_ru",
		"condition" : {
			"type" : "variable",
			"id" : "LANGUAGE",
			"value" : "ru"
		}
	},
	{
		"type" : "optional",
		"path" : "Data/Ground",
		"condition" : {
			"type" : "variable",
			"id" : "GROUND_TEXTURES",
			"value" : true
		}
	}
]

The type of the directory can have the following values:

  • data (all files and directories are modded inside the data directory) (a condition is optional)
  • optional (directory is only modded if the condition is true) (condition is required)

The type of the condition can have the following values:

  • variable (id has to be the id of the defined variable) (condition is true, if the variable has the defined value)
  • mod (id has to be the directory name of the other mod, value is ignored)

Modding

There are two variants of modding the game via DigglesModManager.

Copy

The simple one is the copy mode. You put a file in your mod directory that should be copied into the game directory. If there exists already a file with the same name, a backup of it will be created by DigglesModManager before it will be overwritten.

Change Format

The change mode is a bit tricky, but important to ensure the compatibility of the different mods. When you only want to change a single line in a .tcl file, you do not have to copy the whole file. You can create a change file and define the change.

For example: You want to change the file "Data/Scripts/misc/techtreetunes.tcl". So you create the following file: "Mods/YOURMODNAME/Data/Scripts/misc/change_techtreetunes.tcl" The "change_" at the beginning of the filename gives the signal to DigglesModManager, that you want to change the file and not to copy it.

Inside your change file, you can define multiple commands. Every command begins with a $start line and ends with a $end line. Every command line should be on a single line. The following commands are possible.

Before - Put

After the $before line, you can define the string, that is searched in the original file. After the $put line you can define, what string should added before the searched string. The strings can be more than one line. Then you have to add also the tabs or spaces at the beginning of the lines to find the string correctly.

$start
$before
"Grosse_Holzkiepe" {
$put
"Schubkarren" {
		set tttmaterial_Schubkarren		{Pilzstamm Pilzstamm Pilzstamm Pilzstamm Eisen}
		set tttinvent_Schubkarren			{{exp_Holz 0.19} {exp_Transport 0.25}}
		set tttgain_Schubkarren				{{exp_Holz 0.04}}
		set tttinfluence_Schubkarren		{{exp_Holz 0.3}}
	}
	
$end

This command adds before the string ""Grosse_Holzkiepe" {" the string ""Schubkarren" {...}" with an empty line at the end. So the string in the original game file after modding looks like this:

"Schubkarren" {
		set tttmaterial_Schubkarren		{Pilzstamm Pilzstamm Pilzstamm Pilzstamm Eisen}
		set tttinvent_Schubkarren			{{exp_Holz 0.19} {exp_Transport 0.25}}
		set tttgain_Schubkarren				{{exp_Holz 0.04}}
		set tttinfluence_Schubkarren		{{exp_Holz 0.3}}
	}
"Grosse_Holzkiepe" {

After - Put

After the $after line, you can define the string, that is searched in the original file. After the $put line you can define, what string should added after the searched string. The strings can be more than one line. Then you have to add also the tabs or spaces at the beginning of the lines to find the string correctly.

$start
$after
set tttitems_Saegewerk				{
$put
Schubkarren 
$end

This command adds after the string "set tttitems_Saegewerk {" the string "Schubkarren". So the string in the original game file after modding looks like this:

set tttitems_Saegewerk {Schubkarren

Replace - With

$start
$replace 
Schubkarren food transport
$with
Schubkarren wood transport
$end

Usage of Variables

IF