Script Event Command in RPG Maker MV

nephlm

Villager
Member
Joined
May 20, 2019
Messages
9
Reaction score
1
First Language
English
Primarily Uses
RMMV
Hello Everyone,

I am a bit new so sorry if my question is very basic.

I am trying to write some longer script in RPG Maker MV. Unfortunately, the event command only gives you room for about 12 lines for the script and I have multiple conditional branches and I want to include comments so that I can follow the code. Is there a way that I can get more lines for scripting in the event commands? Would I need a plugin for this?

Also, I have tried continuing my conditional statement by adding another script event command where I left off but I end up getting an error.

Any advice is appreciated.
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
JavaScript only parses newlines as a safety measure: typically a "line" of JS ends with a semi-colon. So, for example, these two snippets are equivalent:
Code:
var vId = 5, sId = 1;
if ($gameVariables.value(vId) >= 10) {
  $gameSwitches.setValue(sId, true);
};
Code:
var vId = 5, sId = 1; if ($gameVariables.value(vId) >= 10) { $gameSwitches.setValue(sId, true); };
Since (I think?) line length is limited, this means your script calls can actually be as long as you like. :kaopride:

I suggest writing it out in a readable way (indents etc) in Notepad or something first, then use that as a reference for entering it into the editor's script box. :kaophew:

Script calls are passed through an eval (slow, inefficient), so if your script is particularly long then you may want to consider writing it up in a separate script file (i.e. a plugin) and simply call that code from your script call. If you want more details on that approach then someone here can probably help with that. :)
 

bazrat

Pixel Game Maker MV
Veteran
Joined
Oct 15, 2018
Messages
241
Reaction score
176
First Language
English
Primarily Uses
Other
JavaScript only parses newlines as a safety measure: typically a "line" of JS ends with a semi-colon. So, for example, these two snippets are equivalent:
Code:
var vId = 5, sId = 1;
if ($gameVariables.value(vId) >= 10) {
  $gameSwitches.setValue(sId, true);
};
Code:
var vId = 5, sId = 1; if ($gameVariables.value(vId) >= 10) { $gameSwitches.setValue(sId, true); };
Since (I think?) line length is limited, this means your script calls can actually be as long as you like. :kaopride:

I suggest writing it out in a readable way (indents etc) in Notepad or something first, then use that as a reference for entering it into the editor's script box. :kaophew:

Script calls are passed through an eval (slow, inefficient), so if your script is particularly long then you may want to consider writing it up in a separate script file (i.e. a plugin) and simply call that code from your script call. If you want more details on that approach then someone here can probably help with that. :)
along with what caethyril said, i also like to make scripts inside moveroutes and conditional branches as convenient for me as i can.

for instance a simple range check of this inside a conditional branch script:
Code:
Math.abs($gameMap.event(e).x - $gamePlayer.x) <= 2 && Math.abs($gameMap.event(e).y - $gamePlayer.y) <= 2
i change so if i need to edit it real quick(remember the script window is so small for a conditional branch command) i use this to make it easier to change:
Code:
var d = 2; Math.abs($gameMap.event(e).x - $gamePlayer.x) <= d && Math.abs($gameMap.event(e).y - $gamePlayer.y) <= d;
now i just gotta change the d variable at begin to whatever i need, which is easily visible inside the conditional branch script window.

its the small things!! :D
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
and depending on what exactly you want, you can write the functions inside a plugin that simply makes them available for global access without any other change in the engine, and then simply use the function call in the script box to run that entire longer code.
After all that is what script calls are and what the script box is intended for: to call the larger script functions from the engine whereever needed.
 

nephlm

Villager
Member
Joined
May 20, 2019
Messages
9
Reaction score
1
First Language
English
Primarily Uses
RMMV
Thank you everyone for the quick responses. I have tried out caethyril and Bazrat's recommendations and for now that it working for my events. I am going to start watching some tutorials on plugins because I imagine that will be helpful in the long term as my scripts get more complex.
 

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

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,446
Members
137,820
Latest member
georg09byron
Top