91
edits
Buttchouda (talk | contribs) (Created page with "A mod in Melvor Idle, much like other games with mods, is a game modification created by the player community. The modification to the game can range from a minor balance change to introducing new skills and items, or a simple quality of life improvement to a full suite of automation tools. There are various programming APIs within Melvor Idle to help you create mods, regardless of how simple or complex it is. == Prerequisites == Mods for Melvor Idle are created using J...") |
Buttchouda (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
== Prerequisites == | == Prerequisites == | ||
Mods for Melvor Idle are created using JavaScript, and at least a beginner level understanding of the language, or programming languages in general, is recommended before jumping into the guides. | Mods for Melvor Idle are created using JavaScript, and at least a beginner level understanding of the language, or programming languages in general, is recommended before jumping into the guides. | ||
Line 7: | Line 8: | ||
== Quick Start == | == Quick Start == | ||
Want to dive right into creating your first mod with a (mostly) blank canvas? Follow along to get started. | Want to dive right into creating your first mod with a (mostly) blank canvas? Follow along to get started. | ||
=== Project Setup === | === Project Setup === | ||
Start by creating a new empty folder for your mod. You'll want to create two files in this new folder: | Start by creating a new empty folder for your mod. You'll want to create two files in this new folder: | ||
* <code>manifest.json</code> | * <code>manifest.json</code> | ||
Line 15: | Line 18: | ||
The <code>manifest.json</code> file is used to define metadata for your mod, or important information for Melvor Idle to know how to load your mod. Put the following code within <code>manifest.json</code>: | The <code>manifest.json</code> file is used to define metadata for your mod, or important information for Melvor Idle to know how to load your mod. Put the following code within <code>manifest.json</code>: | ||
<nowiki>{ | <nowiki>{ | ||
"setup": "setup.mjs" | "setup": "setup.mjs" | ||
Line 20: | Line 24: | ||
This tells Melvor Idle to look for a <code>setup.mjs</code> file and run its exported <code>setup</code> function. Next we'll create that function within <code>setup.mjs</code>: | This tells Melvor Idle to look for a <code>setup.mjs</code> file and run its exported <code>setup</code> function. Next we'll create that function within <code>setup.mjs</code>: | ||
<nowiki>export function setup() { | <nowiki>export function setup() { | ||
console.log('Hello From My Mod!'); | console.log('Hello From My Mod!'); | ||
Line 27: | Line 32: | ||
=== Making it Do Something === | === Making it Do Something === | ||
You'd already have a working "mod" at this point but it's not really modifying anything yet. Let's let the <code>setup</code> function know we want to accept a context object (<code>ctx</code> for short) when <code>setup</code> is executed, and then patch the <code>Skill</code> class to double all XP gains. | You'd already have a working "mod" at this point but it's not really modifying anything yet. Let's let the <code>setup</code> function know we want to accept a context object (<code>ctx</code> for short) when <code>setup</code> is executed, and then patch the <code>Skill</code> class to double all XP gains. | ||
<nowiki>export function setup(ctx) { | <nowiki>export function setup(ctx) { | ||
ctx.patch(Skill, 'addXP').before(function(amount, masteryAction) { | ctx.patch(Skill, 'addXP').before(function(amount, masteryAction) { | ||
Line 39: | Line 46: | ||
=== Using Player Input === | === Using Player Input === | ||
Doubling XP is okay, but the mod would be even more useful if the player could customize the amount that the XP was being multiplied by. Luckily, that's easy with another part of the context object: mod settings. | Doubling XP is okay, but the mod would be even more useful if the player could customize the amount that the XP was being multiplied by. Luckily, that's easy with another part of the context object: mod settings. | ||
You can define a setting for the player to change using the settings object within the context object, and modify the patch code from above to use this value instead of a value of 2: | You can define a setting for the player to change using the settings object within the context object, and modify the patch code from above to use this value instead of a value of 2: | ||
<nowiki>export function setup(ctx) { | <nowiki>export function setup(ctx) { | ||
ctx.settings.section('General').add({ | ctx.settings.section('General').add({ | ||
Line 60: | Line 69: | ||
=== Packaging and Adding Your Mod === | === Packaging and Adding Your Mod === | ||
Once you're ready to test your mod or make it available in the Mod Manager, you'll want to package it and upload it to mod.io. | Once you're ready to test your mod or make it available in the Mod Manager, you'll want to package it and upload it to mod.io. | ||
Line 71: | Line 81: | ||
=== Using Your Mod === | === Using Your Mod === | ||
You'll now be able to subscribe, download, install, and use your mod. If you've made the mod public try searching for it in the in-game Mod Manager and subscribing to it there. Once installed, you'll need to restart the game for the mod to take effect. | You'll now be able to subscribe, download, install, and use your mod. If you've made the mod public try searching for it in the in-game Mod Manager and subscribing to it there. Once installed, you'll need to restart the game for the mod to take effect. | ||
Line 78: | Line 89: | ||
== Next Steps == | == Next Steps == | ||
From here the [[Mod Creation/Essentials]] guide is strongly recommended to learn about the different modding concepts and APIs available to you. | From here the [[Mod Creation/Essentials]] guide is strongly recommended to learn about the different modding concepts and APIs available to you. |
edits