Difference between revisions of "Mod Injections"
(More info to Mod Injection page) |
m (Added categories) |
||
Line 72: | Line 72: | ||
Note that by default, Mod Injections are shown throughout the editor. You can disable them by clicking the "Mod Injections" button in the top left (this will turn off mod injections across the entire game for this session, so be sure to turn it back on again if you want to test things later!) | Note that by default, Mod Injections are shown throughout the editor. You can disable them by clicking the "Mod Injections" button in the top left (this will turn off mod injections across the entire game for this session, so be sure to turn it back on again if you want to test things later!) | ||
[[Category:Modding]] | |||
[[Category:Modding Guides]] |
Latest revision as of 18:02, 24 September 2024
What Are Mod Injections?
For most content in Wildermyth, modding works by creating files at a parallel file structure to the main game within your mod folder, and the mod files either being added to or replacing existing files. (For example, mods/user/myCoolMod/assets/data/themes/wolf.json replacing the original assets/data/themes/wolf.json theme data)
However, sometimes we don't want to replace the whole file! Sometimes we just want to add or change a bit of data to an existing file. Take the "human" aspect, for example. If we want to give all humans a new ability, or change their base stats, we could do it by adding our own version of the assets/data/aspects/humans.json file. That's a pretty common thing that modders might want to do though, and if a player has multiple mods overriding that file, only the highest priority one will have an effect.
Mod Injection lets you make changes to existing json data without needing to overwrite the entire file. This allows multiple mods to edit the humans.json file without overriding each other. Or, if you want to make a change to a certain part of an existing campaign, now that can be done without needing to overwrite the entire campaign or make a separate campaign with that change.
Mod Injection Data Structure
Details on the data for Mod Injections. Most of this is set automatically when creating a mod injection, so if you're just getting started, you may want to skip ahead to "Creating a Mod Injection".
Mod Injection Types
- object: Complex data, like Outcomes, Targets, Plot Steps, etc
- string: A text string, like "rangeFeedback" in a target's missionFeedback, or modifying a specific index of a string list (not usually recommended; using the remove and addStrings fields for an entire stringList is safer)
- expression: An expression (like the "amount" in a Damage Outcome), or an integer or float (like the "encounterScore" of an effect)
- enumeration: A dropdown value, like "role" in a target, or "type" in the Damage Outcome
- bool: A true/false (boolean) value, like "invalidatesSkin" on an aspect
- stringList: A list of Strings, like the "effects" list of an aspect, or the "addAspects" list of the Aspects Outcome
- objectList: A list of complex objects, like the "outcomes" list of an effect, or the "particles" list of an AttackRoll Outcome
- objectMap: A key/value object map, like the nodeTemplates in a dungeon (Omenroad) scenario
- expressionMap: A key/value expression map, like the "stats" of an aspect or monster, or the "expressions" field in an effect
Mod Injection Fields
- jsonPath: The json path we want to inject json at. Path uses slashes to indicate stepping into JsonValues with certain names, ids, or index. e.g. "extraRewardTemplates/standard/[0]/rewards". Regular strings will get a child with the given name, or with an "id" field that matches the string. A number within brackets will get a given index of an array.
- type: The type of mod injection, so we can hide irrelevant fields (see list above)
- mapKey: For a map entry, the key for the entry we want to create or replace
- addJson: The json object we want to add. Used any time a more complex object (i.e. non-string and non-expression) is inserted or changed (Outcomes, Targets, Dungeon nodes, etc)
- listBehavior: If this is at the index of a list (the jsonPath ends in "[x]"), the value can be replaced, or a new value can be inserted at this index
- bool: True/False value
- string: For a string or string map, the string value
- addStrings: For a string array, the strings we want to add
- remove: Removes the given strings or keys from the given array or map
- expression: Expression to replace the existing expression at the given jsonPath, or to add/replace in combination with the mapKey
- enumeration: Enum (dropdown) value
Creating a Mod Injection
Open the Mod Injections page by navigating to Tools > Open Editor > Content and Comics Editor, and then switching from the "comics" page to the "mod injections" page via the dropdown.
Here you'll see two buttons at the top:
- Mod Injection Editor Mode: When Mod Injection Editor Mode is enabled, "Mod Injection" buttons will show up next to data lines that you can click to create new Mod Injections.
- Mod Injections: Editor setting: When enabled, Mod Injections will be applied across the editor and in-game. When disabled, they'll be ignored, showing the original files instead. (Note that this setting applies in-game as well, so don't forget to turn this back on if you want to test your Mod Injections!)
Click the Mod Injection Editor Mode button, and now Mod Injection buttons will show up for most lines of the editor!
An Example: Changing Human Stats
Let's say we want to adjust humans to be a bit less squishy by default, give them a bit more health. Switch over to the aspects tab and view the aforementioned "human" aspect. If you hover over the "HEALTH" stat line, you'll see a "Mod Injection" button.
Click the Mod Injection button, and a New Mod Injection dialog will pop up. Usually, you shouldn't change anything in this dialog, just go ahead and click Create.
Immediately after clicking Create, you should see the mod injection you've just created. You'll note there's an "expression: 5" line. You can change that to whatever you'd like the health to be!
Save the Mod Injection file, and you're done! Mod Injection files are stored in a parallel file structure to the files they modify, in [yourModName]/assets/data/modInjections. For example, the file I just created is stored at mods/user/MyCoolMod/assets/data/modInjections/aspects/humans.json.
For most Mod Injections, if you want to see the changes in context after creating one, you'll want to press the Refresh button in the top-right of the editor. This will cause all data and mods to reload, which will apply your mod injections to the data. (It will probably take a few seconds)
If you switch back over to the mod injections page, you can see all the mod injections you've created:
Mod Injections are stored per file, so if you add more injections to the human aspect, or even to a different aspect in the aspect/humans.json file (e.g. if you made changes to the "farmer" or "humanFemale" aspects), these would all appear in the modInjections list when selecting aspects/humans on the left.
You can also see the Full Object listed on the right. This shows how the file will look with the mod injections applied. (Again, because mod injections are stored per file, when editing aspects you'll be shown a list of all the aspects in the file, which you can scroll through to find the ones you've modified) You can click the "Show Original" button to display what the base file looks like without any mod injections.
Note that by default, Mod Injections are shown throughout the editor. You can disable them by clicking the "Mod Injections" button in the top left (this will turn off mod injections across the entire game for this session, so be sure to turn it back on again if you want to test things later!)