Skip to content

Commit f3341e7

Browse files
rename "ModMain" to "mod_main" + "_meta.json" to "manifest.json" (#26)
1 parent cc3db88 commit f3341e7

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ yourmod.zip
1515
├───.import
1616
└───mods-unpacked
1717
└───Author-ModName
18-
├───ModMain.gd
19-
└───_meta.json
18+
├───mod_main.gd
19+
└───manifest.json
2020
```
2121

2222
#### Notes on .import
@@ -30,10 +30,10 @@ You can copy your custom assets from your project's .import directory. They can
3030

3131
Mods you create must have the following 2 files:
3232

33-
- **ModMain.gd** - The init file for your mod.
34-
- **_meta.json** - Meta data for your mod (see below).
33+
- **mod_main.gd** - The init file for your mod.
34+
- **manifest.json** - Meta data for your mod (see below).
3535

36-
#### Example _meta.json
36+
#### Example manifest.json
3737

3838
```json
3939
{
@@ -85,8 +85,8 @@ yourmod.zip
8585
├───.import
8686
└───mods-unpacked
8787
└───Author-ModName
88-
├───ModMain.gd
89-
├───_meta.json
88+
├───mod_main.gd
89+
├───manifest.json
9090
└───extensions
9191
└───Any files that extend vanilla code can go here, eg:
9292
├───main.gd

loader/mod_loader.gd

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ const MOD_LOG_PATH = "user://mods.log"
4444
const UNPACKED_DIR = "res://mods-unpacked/"
4545

4646
# These 2 files are always required by mods.
47-
# ModMain.gd = The main init file for the mod
48-
# _meta.json = Meta data for the mod, including its dependancies
49-
const REQUIRED_MOD_FILES = ["ModMain.gd", "_meta.json"]
47+
# mod_main.gd = The main init file for the mod
48+
# manifest.json = Meta data for the mod, including its dependancies
49+
const REQUIRED_MOD_FILES = ["mod_main.gd", "manifest.json"]
5050

51-
# Required keys in a mod's _meta.json file
51+
# Required keys in a mod's manifest.json file
5252
const REQUIRED_META_TAGS = [
5353
"id",
5454
"name",
@@ -101,7 +101,7 @@ func _init():
101101

102102
# Loop over all loaded mods via their entry in mod_data. Verify that they
103103
# have all the required files (REQUIRED_MOD_FILES), load their meta data
104-
# (from their _meta.json file), and verify that the meta JSON has all
104+
# (from their manifest.json file), and verify that the meta JSON has all
105105
# required properties (REQUIRED_META_TAGS)
106106
for mod_id in mod_data:
107107
var mod = mod_data[mod_id]
@@ -314,8 +314,8 @@ func _init_mod_data(mod_folder_path):
314314

315315
for required_filename in REQUIRED_MOD_FILES:
316316
# Eg:
317-
# "modmain.gd": local_mod_path + "/ModMain.gd",
318-
# "_meta.json": local_mod_path + "/_meta.json"
317+
# "mod_main.gd": local_mod_path + "/mod_main.gd",
318+
# "manifest.json": local_mod_path + "/manifest.json"
319319
mod_data[mod_id].required_files_path[required_filename] = local_mod_path + "/" + required_filename
320320

321321

@@ -336,21 +336,21 @@ func _check_mod_files(mod_id):
336336
mod_log(str("ERROR - ", mod_id, " cannot be loaded due to missing required files"), LOG_NAME)
337337

338338

339-
# Load meta data into mod_data, from a mod's _meta.json file
339+
# Load meta data into mod_data, from a mod's manifest.json file
340340
func _load_meta_data(mod_id):
341341
mod_log(str("Loading meta_data for -> ", mod_id), LOG_NAME)
342342
var mod = mod_data[mod_id]
343343

344344
# Load meta data file
345-
var meta_path = mod.required_files_path["_meta.json"]
345+
var meta_path = mod.required_files_path["manifest.json"]
346346
var meta_data = _get_json_as_dict(meta_path)
347347

348348
dev_log(str(mod_id, " loaded meta data -> ", meta_data), LOG_NAME)
349349

350350
# Check if the meta data has all required fields
351351
var missing_fields = _check_meta_file(meta_data)
352352
if(missing_fields.size() > 0):
353-
mod_log(str("ERROR - ", mod_id, " ", missing_fields, " are required in _meta.json."), LOG_NAME)
353+
mod_log(str("ERROR - ", mod_id, " ", missing_fields, " are required in manifest.json."), LOG_NAME)
354354
# Flag mod - so it's not loaded later
355355
mod.is_loadable = false
356356
# Continue with the next mod
@@ -373,7 +373,7 @@ func _check_meta_file(meta_data):
373373

374374

375375
# Run dependency checks on a mod, checking any dependencies it lists in its
376-
# meta_data (ie. its _meta.json file). If a mod depends on another mod that
376+
# meta_data (ie. its manifest.json file). If a mod depends on another mod that
377377
# hasn't been loaded, the dependent mod won't be loaded.
378378
func _check_dependencies(mod_id:String, deps:Array):
379379
dev_log(str("Checking dependencies - mod_id: ", mod_id, " dependencies: ", deps), LOG_NAME)
@@ -438,7 +438,7 @@ func _compare_Importance(a, b):
438438
# Instance every mod and add it as a node to the Mod Loader.
439439
# Runs mods in the order stored in mod_load_order.
440440
func _init_mod(mod):
441-
var mod_main_path = mod.required_files_path["ModMain.gd"]
441+
var mod_main_path = mod.required_files_path["mod_main.gd"]
442442
dev_log(str("Loading script from -> ", mod_main_path), LOG_NAME)
443443
var mod_main_script = ResourceLoader.load(mod_main_path)
444444
dev_log(str("Loaded script -> ", mod_main_script), LOG_NAME)

0 commit comments

Comments
 (0)