Accessing variable inside event

Hi,


I have some events which have a variable called _player. This is used to just give them an id number that associates with a player.


I do this by:


$gameMap._events[event]._player = player;


Where player is an integer.


The following works:


alert($gameMap._events[event]._player); // prints an integer




But inside the event, I use this script call:


a = this._player;
window.open(url + a);


a is always undefined.


How do I access the _player variable I have created from inside an event, if not with this._player ?


To clarify this is what I am trying to replicate, but using the currently running event. This works:


a = $gameMap._events[17]._player;
window.open(url + a);


Thanks for your help.
I'm going off VX Ace knowledge here. However, my gut instinct is telling me that, in the context of a script-call, "this" is referring to Game_Interpreter, or the MV equivalent thereof. Unfortunately, the only way I would know how to replicate the effect you are looking for would be to stash the event ID into a variable, and pass it into a function that looks like...


a = $gameMap._events[num]._player;
window.open(url + a);


...this?
When you make a script call on an event, 'this' don't refer to the event, but to the Game_Interpreter.


the Game_Interpreter stores the event Id on 'this._eventId'
Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/accessing-variable-inside-event.63439/