Status
Not open for further replies.

Winek

Veteran
Veteran
Joined
Apr 12, 2017
Messages
34
Reaction score
5
First Language
English
Primarily Uses
RMMV
Thread. I've tried placing two events at the same place, then getting the ID of the event, using $gameMap.eventIdXy(x, y), but it's always returning the lowest event ID. Does anyone have any solution concerning this? Another method, something alternative?

And yes, I need to have two overlapping events, and for me to be able to return both. I'm far in my project, and I don't need another way that doesn't involve events overlapping.

Thank you!
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,952
Reaction score
4,870
First Language
EN, FR
Primarily Uses
RMMZ
Code:
Game_Map.prototype.eventsXy_special = function(x, y) {
    var arr = [];
    this.events().filter(function(event) {
        if (event.pos(x, y)) {
            arr.push(event);
        }
    });
    return arr;
};

Game_Map.prototype.eventIdXy_special = function(x, y) {
    var arr = [];
    var list = this.eventsXy_special(x, y);
    if (list.length > 0) {
        for (var i = 0; i < list.length; i++) {
            arr.push(list[i].eventId());
        }
    }
    return arr;
};

Add this bit of code in the game's code (you can add it as a single plugin for instance). Now, instead of calling the old method you can call the new one: $gameMap.eventIdXy_special(x, y) . This will send you back an array with the id of all events at the position you specify.

Note, I wrote this quickly and have not tested the code. If there's an error just screenshot it and I'll fix it.

Edit: I forgot to move the thread to the appropriate subforum, so...

I've moved this thread to Learning Javascript. Thank you.

 

Sir levée

Hill man of V'scello
Member
Joined
Jan 24, 2014
Messages
19
Reaction score
6
First Language
english
Primarily Uses
RMMV
$gameMap.eventsXy(x, y).length for all events at the location?

$gameMap.eventsXyNt(x, y).length is without the through switch according to another post

So you could set the one with the lower ID to have through checked
$gameMap.eventIdXy(x, y) would grab lowest as normal
$gameMap.eventIdXyNt(x, y) would have to grab the latter
 
Last edited:

Winek

Veteran
Veteran
Joined
Apr 12, 2017
Messages
34
Reaction score
5
First Language
English
Primarily Uses
RMMV
And the code works wonder, MushroomCake28! That saves me a lot of trouble.

Thanks again!
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,952
Reaction score
4,870
First Language
EN, FR
Primarily Uses
RMMZ
@Winek Glad we could help! Can I mark this thread as solved and close it?
 

Winek

Veteran
Veteran
Joined
Apr 12, 2017
Messages
34
Reaction score
5
First Language
English
Primarily Uses
RMMV
Yes indeed! I forgot to report it as solved, so I'll do it now!
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,203
Reaction score
5,998
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Totally original and unique OC
Harold.png
So after completing the Mass Effect Trilogy the first time as a Vanguard, I decided to replay the trilogy as a Soldier. Thus far, I've just finished the Horizon mission in ME2, and I'm already exhausted from ME2's f**k-awful enemy design.
Yeah, now Yes !!!! "boom boom "
"Fire the monsters, guards!!!"

index.php
I can't stop buying resource packs I'll never use, or engines for that matter, or free resources as my two terabyte external will attest. I am a digital hoarder I guess. Some people get drunk off the silly juice when they are bored, I just buy shiny digital nonsense I don't need.
Not a bad weekend but anxiety kicking my but. Also wondering about Ms Littlefish. Some people move on. Anyways how is everyone doing?

Forum statistics

Threads
118,648
Messages
1,117,545
Members
155,747
Latest member
Sapphire456
Top