Skip to content

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:

bash
git clone https://github.com/melonity-public/template-custom-scripts
cd template-custom-scripts

You 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:

bash
npm install

After 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:

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:

txt
...\launcher_files\melonity_dota2\scripts

IMPORTANT

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:

txt
Settings -> Scripts -> Load local scripts

Without 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 F7 to reload scripts and refresh the list

Start compilation

Run the watcher:

bash
npm run watch

Webpack will rebuild the script whenever you change project files.


Check that the environment is ready

Your environment is configured correctly if:

  • npm run watch starts without errors
  • the output .js file appears in the expected directory
  • Load local scripts is enabled in Melonity

Once all of this works, you can move on to creating your first script.