diff --git a/_m3ec/util.py b/_m3ec/util.py index 1205103..e8e5dc1 100644 --- a/_m3ec/util.py +++ b/_m3ec/util.py @@ -101,6 +101,12 @@ def joinDicts(a, b): c[k] = b[k] return c +def getDictKeyLen(d, key): + if key.lower() in d.keys(): + if type(d[key.lower()]) is str: + return len(d[key.lower()]) + return 0 + def checkDictKeyTrue(d, key): if key.lower() in d.keys(): if type(d[key.lower()]) is str: @@ -521,7 +527,7 @@ def add_content(cid, content_type, d, manifest_dict, fname=None): if "_" in cidlow: manifest_dict[f"mod.{content_type}.{cidlow}.class"] = "".join([word.capitalize() for word in cidlow.split("_")]) else: - manifest_dict[f"mod.{content_type}.{cidlow}.class"] = cid + manifest_dict[f"mod.{content_type}.{cidlow}.class"] = cid.capitalize() # if f"mod.{content_type}.{cidlow}.class" in manifest_dict.keys(): # print(manifest_dict[f"mod.{content_type}.{cidlow}.class"]) @@ -532,7 +538,9 @@ def add_content(cid, content_type, d, manifest_dict, fname=None): if content_type == "recipe": manifest_dict[f"mod.{content_type}.{cidlow}.texture"] = d["result"] else: - if f"mod.{content_type}.{cidlow}.texture" not in manifest_dict.keys(): + if "title" not in d.keys() or getDictKeyLen(d, "title") < 1: + manifest_dict["title"] = " ".join([word.capitalize() for word in cidlow.split("_")]) + if "texture" not in d.keys() or getDictKeyLen(d, "texture") < 1: if f"mod.{content_type}.{cidlow}.texture_top" in manifest_dict.keys(): manifest_dict[f"mod.{content_type}.{cidlow}.texture"] = manifest_dict[f"mod.{content_type}.{cidlow}.texture_top"] elif f"mod.{content_type}.{cidlow}.texture_side" in manifest_dict.keys(): @@ -542,7 +550,7 @@ def add_content(cid, content_type, d, manifest_dict, fname=None): elif f"mod.{content_type}.{cidlow}.texture_front" in manifest_dict.keys(): manifest_dict[f"mod.{content_type}.{cidlow}.texture"] = manifest_dict[f"mod.{content_type}.{cidlow}.texture_front"] else: - manifest_dict[f"mod.{content_type}.{cidlow}.texture"] = None + manifest_dict[f"mod.{content_type}.{cidlow}.texture"] = cidlow return True diff --git a/data/default_content_files/food.m3ec b/data/default_content_files/food.m3ec index 8ca0e75..db3b176 100644 --- a/data/default_content_files/food.m3ec +++ b/data/default_content_files/food.m3ec @@ -4,13 +4,18 @@ contentid: title: texture: +# Hunger restore. Player has 20 hunger points. hunger: +# Saturation modifier. Multiplied by hunger to get actual value saturation: # true, false alwaysEdible: true # true, false snack: false +# Haste 2 effect for 15 seconds with a 50% chance of triggering +# +statusEffects: HASTE 2 300 0.5 + # customclass: # +langs: fr_ca # fr_ca: diff --git a/m3ec.py b/m3ec.py index 140fb9c..145eef1 100644 --- a/m3ec.py +++ b/m3ec.py @@ -243,8 +243,11 @@ def build_mod(modloader, version, modenv, manifest_dict): add_content(cid, "item", dictinst, manifest_dict, fname) continue if "contentid" not in d.keys(): - print(f"Warning: Skipping file \"{fname}\" due to missing contentid.") - continue + if "cid" in d.keys(): + d["contentid"] = d["cid"] + else: + print(f"Warning: Skipping file \"{fname}\" due to missing contentid.") + continue if content_type == "recipe": if "contentid" in d.keys(): cid = d["contentid"]