Preparing the environment
This page explains how to prepare a local environment for Melonity script development using the template repository.
Requirements
- Node.js LTS
- Any code editor, for example VS Code or WebStorm
TIP
The template repository already contains a working project structure and an example entry point in src/example.ts.
Create a project from the template
Clone the template repository:
git clone https://github.com/melonity-public/template-custom-scripts
cd template-custom-scriptsYou can also use the Use this template button on GitHub if you want to create your own repository immediately.
Install dependencies
Install the required packages:
npm installAfter that, the project will be ready for compilation.
Configure the build output
By default, the template project builds into a local dist folder next to webpack.config.js:
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
}This is useful for a clean local build, but Melonity will not load files from dist automatically.
If you want the launcher to load your build directly, change output.path to the directory from which Melonity loads local scripts.
The current custom scripts location usually looks like this:
...\launcher_files\melonity_dota2\scriptsIMPORTANT
If the bundle is still written to dist, the script will compile successfully but will not appear in Melonity until you move it or change the output path.
Enable local scripts in the launcher
In Melonity, enable the following option:
Settings -> Scripts -> Load local scriptsWithout this option, local scripts will not be loaded even if the compilation is successful.
After enabling it, Melonity will show a list of all .js files from the local scripts folder.
- if a script is disabled in that list, it will not work
- if you add a new file to the folder, press
F7to reload scripts and refresh the list
Start compilation
Run the watcher:
npm run watchWebpack will rebuild the script whenever you change project files.
Check that the environment is ready
Your environment is configured correctly if:
npm run watchstarts without errors- the output
.jsfile appears in the expected directory Load local scriptsis enabled in Melonity
Once all of this works, you can move on to creating your first script.