siuleeboss

Veteran
Veteran
Joined
Apr 29, 2019
Messages
58
Reaction score
14
First Language
Chinese
Primarily Uses
RMMV
How to get the total number of events for a map?
For example I want to get the length of map 3.
 

BK-tdm

Manga Maker
Veteran
Joined
Jun 21, 2018
Messages
415
Reaction score
1,265
First Language
English
Primarily Uses
RMMV
In the editor? Just make a new event it will automatically number itself "event #X" where X is the total number of events in that map, counting the new dummy event you're making.


For processing it as a number in an event or any other need while the game is running:
You can set a control variable to a script and then add:

$gameMap.events().length

if im not mistaken this should numerically add the number of events on the current map you're in, remember to reset this variable before re-counting on another map.

corrected to proper syntax
 
Last edited:

siuleeboss

Veteran
Veteran
Joined
Apr 29, 2019
Messages
58
Reaction score
14
First Language
Chinese
Primarily Uses
RMMV
For MV it would be $gameMap.events().length.

Edit: ninja'd.
Hi there!

Inside the game you can check the number of map events with the script call:

$gameMap.events().length


@BK-tdm I believe that is a VX Ace syntax? On MV and MZ it's a little bit different ^^
In the editor? Just make a new event it will automatically number itself "event #X" where X is the total number of events in that map, counting the new dummy event you're making.


For processing it as a number in an event or any other need while the game is running:
You can set a control variable to a script and then add:

$gameMap.events().length

if im not mistaken this should numerically add the number of events on the current map you're in, remember to reset this variable before re-counting on another map.

corrected to proper syntax
But
$gameMap.events().length
this can only check the number of events on the map where the player is located, not the number of events on the specified map.
For example the player is on map 1, but I want to check the number of events on map 3
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,342
Reaction score
1,548
First Language
English
Primarily Uses
Other
  1. Load the json of the map in question
  2. Check the length of the event element.

The async nature of loading files makes the first step a bit difficult.
Perhaps you can scavenge some code from an abandoned plugin I had lying around:
If you know you'll only run the code in a place where 'fs' is available then using that to load will be easier. Checkout out my MoarMaps Helper plugin for an example of how to do that:
Note: While my plugins are aimed at MZ the code for loading map files shouldn't be too different in MV

*hugs*
- Zeriab
 

Latest Threads

Latest Posts

Latest Profile Posts

Hello! Can anyone help me? I followed making cooking tutorial for RPG Maker MV. But for some reason buff state that food gives doesn't work in overworld. It disappears. What am I supposed to do?
A shotgun is not a rifle. Huh.
SIGH its so hard to convince my friend that making a game for fun and making one to sell takes different planning. I don't care about weird bothersome ways of doing things in a game made for fun, but when you are planning to market it, there is some stuff that you just have to streamline or cut out.
It might be a little bit boring and tedious, but building that database of armor, items, weapons and skills are super important.

Forum statistics

Threads
124,399
Messages
1,163,341
Members
163,195
Latest member
new88betscom
Top