Getting an events name?

Code:
var Nekohime = Nekohime || {};
Nekohime.Game_Event_initMembers = Game_Event.prototype.initMembers;
Game_Event.prototype.initMembers = function(){
  Nekohime.Game_Event_initMembers.call(this);
  this._name = name;
}
Game_Event.prototype.name = function(){
  return this._name;
}

I'm trying to create a function that returns an events name. (as stored in $datamap)
But it returns null. No errors.
the problem is that you're just saying "this._name = name;" in the initMembers method, and name, is not actually defined.

In reality you don't need to access the initMembers method to make the name method. This should work.
Code:
Game_Event.prototype.name = function() {
    return this.event() ? this.event().name : ""; // if event data exists for this event.
    // return the name of the event, otherwise if it doesn't return a blank string.
};

hope this helps. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/getting-an-events-name.113853/