Hisao Shou

Veteran
Veteran
Joined
Jan 8, 2015
Messages
164
Reaction score
23
Primarily Uses
Hello there, I'm new in javascript programming, and I'm having difficulties to get an array of map ids for $gameMap.event.

I basically want to do Something like:

var arr = [3, 5, 6]; //array of certain events
return $gameMap.event(arr); //returns to any event which has the ids from array

Can someone please help me with this?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,646
First Language
Czech
Primarily Uses
RMMV
arr is an array and $gameMap.event accepts only an integer.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,259
Reaction score
1,666
First Language
EN
Primarily Uses
RMMZ
I'm guessing you want to return an array of event objects corresponding to those event IDs? In which case you could try something like this:
Code:
var ids = [3,4,5];
return ids.map(function(id) {
  return $gameMap.event(id);
});
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,821
Reaction score
4,754
First Language
English
Primarily Uses
RMMZ
Also, if my memory serves me correctly, $gameMap is an object that only contains information on the current map, not all maps. The game doesn't load all maps to save on memory usage. Data for all maps are kept as json files and are only read (process of taking that info and storing it in $gameMap to replace the data of the old map) when you change map.

(Sorry, I just noticed that you're talking about event ids and not map ids. Your first sentence is confusing me: "I'm having difficulties to get an array of map ids for $gameMap.event.")

For what I think you want to achieve, the above post would be your solution. If it's something else, please be more precise.
 

Hisao Shou

Veteran
Veteran
Joined
Jan 8, 2015
Messages
164
Reaction score
23
Primarily Uses
I'm guessing you want to return an array of event objects corresponding to those event IDs? In which case you could try something like this:
Code:
var ids = [3,4,5];
return ids.map(function(id) {
  return $gameMap.event(id);
});
Thank you very much! This worked
 

Latest Threads

Latest Posts

Latest Profile Posts

Today we be doing an unscheduled stream! Lets get some work done on the titlescreen for Lightestone! <3
www.twitch.tv/riazey
I can't believe it... my mom is going to sign me up for the Planet Fitness down the street! I need to lower my cholesterol according to my doctor, and I'll need to lose some weight to fit into Helen Henny's skirt (I ordered a skirt for my mascot outfit and realized it was a bit too small). My doctor says I need to lose weight anyway.
I blame my lilest bro for the duck suit. Sketched it and realized it had to be added to a mock fashion magazine cover. The titles are actually inside jokes about the place this NPC is from.
EvKECQJVEAw3Qux
Kes
After a few hectic months, my hiatus is over, and I'm now back. Good to see so many familiar names posting. And a forum update while I was away.
V1.3 of Demo, a new concept artist on the team, character voices are coming into light more... I'm happy to say that the fangame is making good progress.

Forum statistics

Threads
108,855
Messages
1,040,096
Members
141,300
Latest member
Torcham
Top