Load JavaScript file instead of typing in code?

Hi!

I'm just starting to explore different options in MV. The JavaScript text box in the Movement Route dialogue is really tiny. Is it (possible|a good idea) to have the code in a separate file and put an include statement in the text box instead?

Also, I'm not very good at JavaScript, so I'm not even sure about the method for including a file. Does one have to use export/import?

Thanks!
If you want to do something complex in the movement route script box, I'd recommend creating a plugin that just defines a function, like this:

JavaScript:
Game_CharacterBase.prototype.yourFunction = function(maybe, some, parameters) {
  // do your thing here
}

Then with that plugin loaded in the plugin manager, you can just call the function like this.yourFunction(maybe, some, parameters) in the movement route script box.

There is (as far as I know) no function in RMMV JavaScript to "load and execute this file right now", but the above technique should be good enough.
Awesome, thanks! I think that's a better way to do it than to just brute import code from a text file.
Just to close the loop on this...

What I really wanted was a function that calculates some things and that I can put in a condition. I ended up trying

Code:
Game_Interpreter.prototype.playerClose = function(){

    return true;
}

which worked as desired in the event's

Skärmklipp 2020-07-08 18.37.51.png


I.e., it triggered the first option. Very rudimentary stuff, but baby steps etc. So, thanks again.
Yeah, I definitely remember doing something similar when I wanted to know whether the player is facing a particular event or tile.

Original thread: https://forums.rpgmakerweb.com/threads/load-javascript-file-instead-of-typing-in-code.123803/