Getting array for $gameMap.event

Discussion in 'Javascript/Plugin Support' started by Hisao Shou, Jul 19, 2019.

  1. Hisao Shou

    Hisao Shou Veteran Veteran

    Messages:
    87
    Likes Received:
    13
    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?
     
    #1
  2. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,786
    Likes Received:
    9,471
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    arr is an array and $gameMap.event accepts only an integer.
     
    #2
  3. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,054
    Likes Received:
    659
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    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);
    });
     
    #3
  4. MushroomCake28

    MushroomCake28 KAMO Studio Veteran

    Messages:
    1,629
    Likes Received:
    2,935
    Location:
    Montreal, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    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.
     
    #4
    caethyril likes this.
  5. Hisao Shou

    Hisao Shou Veteran Veteran

    Messages:
    87
    Likes Received:
    13
    Thank you very much! This worked
     
    #5
    caethyril likes this.

Share This Page