Load JavaScript file instead of typing in code?

Kronicide

Veteran
Veteran
Joined
Jul 7, 2020
Messages
33
Reaction score
12
First Language
Swedish
Primarily Uses
RMMV
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!
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
478
Reaction score
210
First Language
English
Primarily Uses
RMMV
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.
 

Kronicide

Veteran
Veteran
Joined
Jul 7, 2020
Messages
33
Reaction score
12
First Language
Swedish
Primarily Uses
RMMV
Awesome, thanks! I think that's a better way to do it than to just brute import code from a text file.
 

Kronicide

Veteran
Veteran
Joined
Jul 7, 2020
Messages
33
Reaction score
12
First Language
Swedish
Primarily Uses
RMMV
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.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
478
Reaction score
210
First Language
English
Primarily Uses
RMMV
Yeah, I definitely remember doing something similar when I wanted to know whether the player is facing a particular event or tile.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

ESAMarathon on Twitch, now streaming "Eat Girl". Yep, that's the title of a game... Apparently it's a Pacman knockoff.... Which is of course the only logical conclusion one would get from a name like "Eat Girl". :kaopride: I can't believe anybody would think anything else! :kaoback:
Super stoked i just finished my first town in my project, by finished i mean i can always add more decorative aesthetics and the NPCs don't talk yet but the mapping is complete and all the important chess pieces are present!
My brain: Hey, I have an idea how to make the transition to the main story quest in The Wastes more natural!
Me: Good!
My brain: You need to remake the hotel you start out in, it's not realistic enough.
Me: Ok... This was unexpected, but I can do it.
My brain: Now make each hotel floor 5 times as large to match the main part. Oh, you also need to make a bunch of new npcs to fill in the space on these maps.
Me: Crap.
Should be able to release Haxe MV/MZ next weekend.
It look that somehow MZ tracks are messed up (for example battle4 is obviously a theme, castle2 is a ship, ship1 is a scene and so on..). Maybe they just named them after with some ambiguity.

Forum statistics

Threads
100,611
Messages
977,813
Members
132,227
Latest member
YourBaka
Top