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,269
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,549
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

yo i made a post but it hasnt really gotten any answers so uhhhh
Finished switching to a new PC. Now I could potentially start working at projects or plugins again if I feel the motivation to do so.
If you don't read the news, you are uninformed. If you read the news, you are misinformed.
Custom slip rates and custom ailment durations for enemies really opens up the floodgates for status effect use. I can have Poison and Time Stop affect bosses without it breaking their balance! Finally, a healthy middle ground.

(Especially after I cooked up a thing that prevents you from re-applying deadly states more than once in specific occassions.)
Voice.gif
The Voice... They usually show up to talk to you about leaving your mark on the world, which is one of the major themes of my game... How will you be remembered by society.

Forum statistics

Threads
124,534
Messages
1,164,276
Members
163,366
Latest member
kurutami
Top