Skip to content

Commit b61787b

Browse files
committed
Merge branch 'main' into move_other_utils
# Conflicts: # addons/mod_loader/mod_data.gd
2 parents 6bbcf08 + 8aadd85 commit b61787b

File tree

3 files changed

+51
-109
lines changed

3 files changed

+51
-109
lines changed

README.md

Lines changed: 6 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,11 @@
22

33
A general purpose mod-loader for GDScript-based Godot Games.
44

5-
See the [Uncyclo](https://github.com/GodotModding/godot-mod-loader/wiki) for additional details, including [Helper Methods](https://github.com/GodotModding/godot-mod-loader/wiki/Helper-Methods) and [CLI Args](https://github.com/GodotModding/godot-mod-loader/wiki/CLI-Args).
5+
## Getting Started
66

7+
View the [Uncyclo](https://github.com/GodotModding/godot-mod-loader/wiki/) for more information.
78

8-
## Mod Setup
9-
10-
For more info, see the [docs for Delta-V Modding](https://gitlab.com/Delta-V-Modding/Mods/-/blob/main/MODDING.md), upon which ModLoader is based. The docs there cover mod setup in much greater detail.
11-
12-
### Structure
13-
14-
Mod ZIPs should have the structure shown below. The name of the ZIP is arbitrary.
15-
16-
```
17-
yourmod.zip
18-
├───.import
19-
└───mods-unpacked
20-
└───Author-ModName
21-
├───mod_main.gd
22-
└───manifest.json
23-
```
24-
25-
#### Notes on .import
26-
27-
Adding the .import directory is only needed when your mod adds content such as PNGs and sound files. In these cases, your mod's .import folder should **only** include your custom assets, and should not include any vanilla files.
28-
29-
You can copy your custom assets from your project's .import directory. They can be easily identified by sorting by date. To clean up unused files, it's helpful to delete everything in .import that's not vanilla, then run the game again, which will re-create only the files that are actually used.
30-
31-
32-
### Required Files
33-
34-
Mods you create must have the following 2 files:
35-
36-
- **mod_main.gd** - The init file for your mod.
37-
- **manifest.json** - Meta data for your mod (see below).
38-
39-
#### Example manifest.json
40-
41-
```json
42-
{
43-
"name": "ModName",
44-
"namespace": "AuthorName",
45-
"version_number": "1.0.0",
46-
"description": "Mod description goes here",
47-
"website_url": "https://github.com/example/repo",
48-
"dependencies": [
49-
"Add IDs of other mods here, if your mod needs them to work"
50-
],
51-
"extra": {
52-
"godot": {
53-
"id": "AuthorName-ModName",
54-
"incompatibilities": [
55-
"Add IDs of other mods here, if your mod conflicts with them"
56-
],
57-
"authors": ["AuthorName"],
58-
"compatible_mod_loader_version": "3.0.0",
59-
"compatible_game_version": ["0.6.1.6"],
60-
"config_defaults": {}
61-
}
62-
}
63-
}
64-
```
65-
66-
## Credits
67-
68-
🔥 ModLoader is based on the work of these brilliant people 🔥
69-
70-
- [Delta-V-Modding](https://gitlab.com/Delta-V-Modding/Mods)
9+
1. Add ModLoader to your [Godot Project](https://github.com/GodotModding/godot-mod-loader/wiki/Godot-Project-Setup).
10+
1. Create your [Mod Structure](https://github.com/GodotModding/godot-mod-loader/wiki/Mod-Structure)
11+
1. Create your [Mod Files](https://github.com/GodotModding/godot-mod-loader/wiki/Mod-Files)
12+
1. Use the [API Methods](https://github.com/GodotModding/godot-mod-loader/wiki/API-Methods)

addons/mod_loader/mod_data.gd

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
extends Resource
22
class_name ModData
33

4-
## Stores and validates all Data required to load a mod successfully
5-
## If some of the data is invalid, [member is_loadable] will be false
4+
# Stores and validates all Data required to load a mod successfully
5+
# If some of the data is invalid, [member is_loadable] will be false
66

77
const LOG_NAME := "ModLoader:ModData"
88

9-
## These 2 files are always required by mods.
10-
## [i]mod_main.gd[/i] = The main init file for the mod
11-
## [i]manifest.json[/i] = Meta data for the mod, including its dependencies
9+
# These 2 files are always required by mods.
10+
# [i]mod_main.gd[/i] = The main init file for the mod
11+
# [i]manifest.json[/i] = Meta data for the mod, including its dependencies
1212
enum required_mod_files {
1313
MOD_MAIN,
1414
MANIFEST,
1515
}
1616

17-
## Directory of the mod. Has to be identical to [method ModManifest.get_mod_id]
17+
# Directory of the mod. Has to be identical to [method ModManifest.get_mod_id]
1818
var dir_name := ""
19-
## Path to the Mod's Directory
19+
# Path to the Mod's Directory
2020
var dir_path := ""
21-
## False if any data is invalid
21+
# False if any data is invalid
2222
var is_loadable := true
23-
## Is increased for every mod depending on this mod. Highest importance is loaded first
23+
# Is increased for every mod depending on this mod. Highest importance is loaded first
2424
var importance := 0
25-
## Contents of the manifest
25+
# Contents of the manifest
2626
var manifest: ModManifest
27-
## Updated in _load_mod_configs
27+
# Updated in _load_mod_configs
2828
var config := {}
2929

30-
## only set if DEBUG_ENABLE_STORING_FILEPATHS is enabled
30+
# only set if DEBUG_ENABLE_STORING_FILEPATHS is enabled
3131
var file_paths := []
3232

3333

3434
func _init(_dir_path: String) -> void:
3535
dir_path = _dir_path
3636

3737

38-
## Load meta data from a mod's manifest.json file
38+
# Load meta data from a mod's manifest.json file
3939
func load_manifest() -> void:
4040
if not has_required_files():
4141
return
@@ -57,7 +57,7 @@ func load_manifest() -> void:
5757
manifest = mod_manifest
5858

5959

60-
## Validates if [member dir_name] matches [method ModManifest.get_mod_id]
60+
# Validates if [member dir_name] matches [method ModManifest.get_mod_id]
6161
func is_mod_dir_name_same_as_id() -> bool:
6262
var manifest_id := manifest.get_mod_id()
6363
if not dir_name == manifest_id:
@@ -67,7 +67,7 @@ func is_mod_dir_name_same_as_id() -> bool:
6767
return true
6868

6969

70-
## Confirms that all files from [member required_mod_files] exist
70+
# Confirms that all files from [member required_mod_files] exist
7171
func has_required_files() -> bool:
7272
var file_check := File.new()
7373

@@ -80,12 +80,12 @@ func has_required_files() -> bool:
8080
return is_loadable
8181

8282

83-
## Validates if manifest is set
83+
# Validates if manifest is set
8484
func has_manifest() -> bool:
8585
return not manifest == null
8686

8787

88-
## Converts enum indices [member required_mod_files] into their respective file paths
88+
# Converts enum indices [member required_mod_files] into their respective file paths
8989
func get_required_mod_file_path(required_file: int) -> String:
9090
match required_file:
9191
required_mod_files.MOD_MAIN:

addons/mod_loader/mod_manifest.gd

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
extends Resource
2-
## Stores and validates contents of the manifest set by the user
2+
# Stores and validates contents of the manifest set by the user
33
class_name ModManifest
44

55

6-
## Mod name.
7-
## Validated by [method is_name_or_namespace_valid]
6+
# Mod name.
7+
# Validated by [method is_name_or_namespace_valid]
88
var name := ""
9-
## Mod namespace, most commonly the main author.
10-
## Validated by [method is_name_or_namespace_valid]
9+
# Mod namespace, most commonly the main author.
10+
# Validated by [method is_name_or_namespace_valid]
1111
var namespace := ""
12-
## Semantic version. Not a number, but required to be named like this by Thunderstore
13-
## Validated by [method is_semver_valid]
12+
# Semantic version. Not a number, but required to be named like this by Thunderstore
13+
# Validated by [method is_semver_valid]
1414
var version_number := "0.0.0"
1515
var description := ""
1616
var website_url := ""
17-
## Used to determine mod load order
17+
# Used to determine mod load order
1818
var dependencies := [] # Array[String]
1919

2020
var authors := [] # Array[String]
21-
## only used for information
21+
# only used for information
2222
var compatible_game_version := [] # Array[String]
23-
## only used for information
23+
# only used for information
2424
var incompatibilities := [] # Array[String]
2525
var tags := [] # Array[String]
2626
var description_rich := ""
2727
var image: StreamTexture
2828

2929

30-
## Required keys in a mod's manifest.json file
30+
# Required keys in a mod's manifest.json file
3131
const REQUIRED_MANIFEST_KEYS_ROOT = [
3232
"name",
3333
"namespace",
@@ -38,7 +38,7 @@ const REQUIRED_MANIFEST_KEYS_ROOT = [
3838
"extra",
3939
]
4040

41-
## Required keys in manifest's `json.extra.godot`
41+
# Required keys in manifest's `json.extra.godot`
4242
const REQUIRED_MANIFEST_KEYS_EXTRA = [
4343
"authors",
4444
"compatible_mod_loader_version",
@@ -48,8 +48,8 @@ const REQUIRED_MANIFEST_KEYS_EXTRA = [
4848
]
4949

5050

51-
## Takes the manifest as [Dictionary] and validates everything.
52-
## Will return null if something is invalid.
51+
# Takes the manifest as [Dictionary] and validates everything.
52+
# Will return null if something is invalid.
5353
func _init(manifest: Dictionary) -> void:
5454
if (not dict_has_fields(manifest, REQUIRED_MANIFEST_KEYS_ROOT) or
5555
not dict_has_fields(manifest.extra, ["godot"]) or
@@ -79,21 +79,21 @@ func _init(manifest: Dictionary) -> void:
7979
# image StreamTexture
8080

8181

82-
## Mod ID used in the mod loader
83-
## Format: {namespace}-{name}
82+
# Mod ID used in the mod loader
83+
# Format: {namespace}-{name}
8484
func get_mod_id() -> String:
8585
return "%s-%s" % [namespace, name]
8686

8787

88-
## Package ID used by Thunderstore
89-
## Format: {namespace}-{name}-{version_number}
88+
# Package ID used by Thunderstore
89+
# Format: {namespace}-{name}-{version_number}
9090
func get_package_id() -> String:
9191
return "%s-%s-%s" % [namespace, name, version_number]
9292

9393

94-
## A valid namespace may only use letters (any case), numbers and underscores
95-
## and has to be longer than 3 characters
96-
## /^[a-zA-Z0-9_]{3,}$/
94+
# A valid namespace may only use letters (any case), numbers and underscores
95+
# and has to be longer than 3 characters
96+
# /^[a-zA-Z0-9_]{3,}$/
9797
static func is_name_or_namespace_valid(name: String) -> bool:
9898
var re := RegEx.new()
9999
re.compile("^[a-zA-Z0-9_]*$") # alphanumeric and _
@@ -110,9 +110,9 @@ static func is_name_or_namespace_valid(name: String) -> bool:
110110
return true
111111

112112

113-
## A valid semantic version should follow this format: {mayor}.{minor}.{patch}
114-
## reference https://semver.org/ for details
115-
## /^[0-9]+\\.[0-9]+\\.[0-9]+$/
113+
# A valid semantic version should follow this format: {mayor}.{minor}.{patch}
114+
# reference https://semver.org/ for details
115+
# /^[0-9]+\\.[0-9]+\\.[0-9]+$/
116116
static func is_semver_valid(version_number: String) -> bool:
117117
var re := RegEx.new()
118118
re.compile("^[0-9]+\\.[0-9]+\\.[0-9]+$")
@@ -125,22 +125,22 @@ static func is_semver_valid(version_number: String) -> bool:
125125
return true
126126

127127

128-
## Returns an empty String if the key does not exist
128+
# Returns an empty String if the key does not exist
129129
static func _get_string_from_dict(dict: Dictionary, key: String) -> String:
130130
if not dict.has(key):
131131
return ""
132132
return dict[key]
133133

134134

135-
## Returns an empty Array if the key does not exist
135+
# Returns an empty Array if the key does not exist
136136
static func _get_array_from_dict(dict: Dictionary, key: String) -> Array:
137137
if not dict.has(key):
138138
return []
139139
return dict[key]
140140

141141

142-
## Works like [method Dictionary.has_all],
143-
## but allows for more specific errors if a field is missing
142+
# Works like [method Dictionary.has_all],
143+
# but allows for more specific errors if a field is missing
144144
static func dict_has_fields(dict: Dictionary, required_fields: Array) -> bool:
145145
var missing_fields := required_fields
146146

0 commit comments

Comments
 (0)