Mod Creation/Enabling DevTools for the Steam and Epic Clients: Difference between revisions

From Melvor Idle
m (Loading Scripts formatting)
No edit summary
 
(51 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{V|0.20}}
For mod developers, it may be beneficial to enable DevTools within the Steam or Epic client. This can be achieved by following the process detailed below. This is a one off operation and does not need to be repeated, that is unless the Steam or Epic client is uninstalled or reinstalled, or when the game client updates.
'''Disclaimer:''' It is highly recommended to '''BACKUP YOUR SAVE''' before running any scripts or extensions.
=== Enabling DevTools for Steam & Epic ===
 
'''Disclaimer:''' Do not run code you can not understand or do not trust. Malicious code could be included in any script and extension.
 
=Before You Begin=
It's highly recommended before doing anything to
# back up your save by exporting or downloading the save file.
# read all instructions before following them.
# verify the code is not malicious.
 
=Steam Console and Scripts=
How to use console commands, scripts, and extensions on Steam.
 
===Setup===
You only have to do this once.
# Download Melvor Idle on Steam, and find the installation directory. e.g. [...]/steamapps/common/Melvor Idle
# Download the 0.49.2 version of NW.js SDK. The version might change in the future, but you need the specific one listed.
#* 64bit Windows: https://dl.nwjs.io/v0.49.2/nwjs-sdk-v0.49.2-win-x64.zip
#* 64bit Linux: https://dl.nwjs.io/v0.49.2/nwjs-sdk-v0.49.2-linux-x64.tar.gz
#* Others: https://dl.nwjs.io/
# Download the scripts and extensions you want to use.
#* Download from the script manager website. e.g. GreasyFork
#* Download from the extension's browser store page.
#* Download the source from the extension's repository. e.g.
#** Combat Sim: https://github.com/visua0/Melvor-Idle-Combat-Simulator-Reloaded/releases
#** SEMI: https://gitlab.com/aldousWatts/SEMI/-/archive/main/SEMI-main.zip
# Extract all zipped files.
# Place the contents of the nwjs-sdk* directory in the Melvor Idle installation directory.
# Place the icons, styles, and source (i.e. scripts or sources) directories of the extracted extensions in the Melvor Idle installation directory.
 
===Loading Scripts===
Loading scripts must be run every time the game is opened on Steam.
<ol>
<ol>
<li>Open the game and load a character.</li>
<li>Ensure Melvor Idle is closed - modifying game files while the game is running may result in unexpected behaviour</li>
<li>Open the dev tools console (F12).</li>
<li>Download Melvor Idle on Steam or Epic, and find the installation folder. e.g. <code>[...]/steamapps/common/Melvor Idle</code>
<li>Set the context of the console to game.</li>
<br/>Not sure where it's installed? It is possible to locate the installation folder through the Steam & Epic clients:</li>
<ul>
<li>The top left of the console has a dropdown: change it from top to game (steam.melvoridle.com). After doing this, you can use the console.</li>
</ul>
<li>Load the scripts and extensions you placed in the installation directory before.</li>
<ul>
<ul>
<li>You can load SEMI like this:</li>
<li>'''Steam:''' Locate Melvor Idle within your library, right click, then click <code>Properties</code> - a window should appear. Within this window, click <code>Installed Files</code> <code>Browse..</code></li>
<pre>require('fs').readFile('scripts/SEMI.js', 'utf8', (err, data) => {eval(data);})
<li>'''Epic:''' Locate Melvor Idle within your library, right click, then click <code>Manage</code> - a window should appear. Within this window, click on the folder icon within the Installation section
$(document.head).append(`<link rel="stylesheet" href="${chrome.runtime.getURL('styles/semi.css')}">`)</pre>
<li>You can load the Combat Simulator like this:</li>
<pre>require('fs').readFile('sources/contentScript.js', 'utf8', (err, data) => {eval(data);})
$(document.head).append(`<link rel="stylesheet" href="${chrome.runtime.getURL('styles/mainStyle.css')}">`)</pre>
<li>You can load user scripts like this, by changing the file name:</li>
<pre>require('fs').readFile('relativePathToMyReallyCoolScript.js', 'utf8', (err, data) => {eval(data);})</pre>
</ul>
</ul>
<li>Open the <code>package.nw</code> folder then <code>package.json</code>. Inside <code>package.json</code>, find <code>"chromium-args":</code> and then remove <code>--disable-devtools</code> and save the changes.</li>
<li>Verify DevTools have been successfully enabled by opening Melvor Idle, then pressing the F12 key once loaded. If successful, the DevTools window should appear</li>
</ol>
</ol>


===Alternate Variation===
{{ModGuideNav}}
The following variant results in a cleaner directory without potential file name clashes. Note that the above does not clash for Combat Simulator + SEMI at the moment.
 
The (cleaner) way I do it mainly differs in the target location of steps (4) and (5) : I made a directory Extensions in the Melvor Idle installation directory, in which I made new directories for the extensions and scripts:
Extensions/
  Greasy Fork/
    Melvor Completion Log Helper.js
    Melvor Idle - Timestamped Saves.js
  Melvor-ETA/
    time-remaining.js
  MICS-steam/
    icons/
    sources/
    styles/
  scripts/
    nameOfMyReallyCoolScript.js
  SEMI-steam/
    icons/
    scripts/
    styles/
 
The script in (9) then has to be changed accordingly:
[
    // own
    'Extensions/scripts/nameOfMyReallyCoolScript.js',
    'Extensions/Melvor-ETA/time-remaining.js',
 
    // extensions
    // other than the main script, extensions typically also require the insertion of a css file
    'Extensions/MICS-steam/sources/contentScript.js',
    //'Extensions/SEMI-steam/scripts/SEMI.js',
 
    // Greasy Fork user scripts
    'Extensions/Greasy Fork/Melvor Completion Log Helper.js',
    'Extensions/Greasy Fork/Melvor Idle - Timestamped Saves.js',
].forEach(pts => require('fs').readFile(pts, 'utf8', (err, data) => {eval(data);}));
 
// Extension css
[
    'Extensions/MICS-steam/styles/mainStyle.css',
    //'Extensions/SEMI-steam/styles/semi.css',
].forEach(cssFile => $(document.head).append(`<link rel="stylesheet" href="${chrome.runtime.getURL(cssFile)}">`));
 
Note that SEMI is commented here since I don't use that, you can easily swap scripts in and out by commenting them. Personally I keep a copy of this script saved as yet another script, and each time I load the game I just copy paste it in the console.
Additionally. this variant approach (C) needs an additional setup step if you are using extensions:
(5.1) Edit the main extension script, i.e. contentScript.js for Combat Simulator and SEMI.js for SEMI, so all source files and icons can be found. In particular you will find references to the icons and source directories in these files, replace these with the appropriate paths:
- Combat Simulator:
- - icons/ -> Extensions/MICS-steam/icons/
- - sources/ -> Extensions/MICS-steam/sources/
- SEMI:
- - icons/ -> Extensions/SEMI-steam/icons/
- - scripts/ -> Extensions/SEMI-steam/scripts/
 
==Auto-loading Scripts in Steam==
# Create a .js file in the Melvor Idle directory.
# Set the contents of the .js file
setTimeout(function(){
      /*insert all of the commands you would normally put in the console to load your scripts*/
}, 15000);
/* the 15000 is just to give the game 15 seconds to get up and running, it doesn't seem to matter if it fires on the character screen or once you load a character.*/
# Add the following code to the parameters of package.json
"inject_js_end": "pathToYourFile/yourFileName.js"
 
{{Menu}}
{{Menu}}
[[Category:Guides]]

Latest revision as of 01:39, 27 January 2024

For mod developers, it may be beneficial to enable DevTools within the Steam or Epic client. This can be achieved by following the process detailed below. This is a one off operation and does not need to be repeated, that is unless the Steam or Epic client is uninstalled or reinstalled, or when the game client updates.

Enabling DevTools for Steam & Epic

  1. Ensure Melvor Idle is closed - modifying game files while the game is running may result in unexpected behaviour
  2. Download Melvor Idle on Steam or Epic, and find the installation folder. e.g. [...]/steamapps/common/Melvor Idle
    Not sure where it's installed? It is possible to locate the installation folder through the Steam & Epic clients:
    • Steam: Locate Melvor Idle within your library, right click, then click Properties - a window should appear. Within this window, click Installed FilesBrowse..
    • Epic: Locate Melvor Idle within your library, right click, then click Manage - a window should appear. Within this window, click on the folder icon within the Installation section
  3. Open the package.nw folder then package.json. Inside package.json, find "chromium-args": and then remove --disable-devtools and save the changes.
  4. Verify DevTools have been successfully enabled by opening Melvor Idle, then pressing the F12 key once loaded. If successful, the DevTools window should appear