Getting an events name?

Nekohime1989

Veteran
Veteran
Joined
May 31, 2014
Messages
345
Reaction score
158
First Language
English
Primarily Uses
N/A
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.
 

chaucer

Veteran
Veteran
Joined
Aug 6, 2014
Messages
265
Reaction score
408
First Language
English
Primarily Uses
RMMV
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. :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Love it when someone confuses "RPG Maker (or script/plugin) has a bug" with "I didn't set it up right and it's not working as I want (or gives an error)"
Is animation really as hard as I think it is?
Out of sudden, snow. Everywhere.
Blech. I hate coming up with stories. Making gameplay is fun but coming up with lore and reasons for these areas/mechanics just makes me sleepy.

Forum statistics

Threads
94,572
Messages
921,999
Members
124,440
Latest member
YukiYuki
Top