1

At the moment iam developing a Game in JavaScript. I have the following Code which runs when an Object ($gameMap.events()[eventId]) is created:

var _GameEvent_initialize = Game_Event.prototype.initialize;
Game_Event.prototype.initialize = function(mapId, eventId) {
    _GameEvent_initialize.call(this, mapId, eventId);
    if (this.isEnemy()) {
            this._eventEnemyId = this.isEnemy();
            console.log(this._eventEnemyId);

            this._eventEnemyHP = $dataEnemies[this._eventEnemyId].params[0];
            console.log(this._eventEnemyHP);
            this._eventEnemyATK = $dataEnemies[this._eventEnemyId].params[2]; // ATK
            this._eventEnemyDEF = $dataEnemies[this._eventEnemyId].params[3]; // DEF
            this._eventEnemyDEX = $dataEnemies[this._eventEnemyId].params[6]; // DEX
            this._eventEnemyLCK = $dataEnemies[this._eventEnemyId].params[7]; // LCK
            console.log("TRUMP!");
            this._isEnemy = true;
    }
        this.test = "lel";
}

The console tells me, that it runs trough the IF. It looks like this:

1
50
TRUMP!

Also the object contains the variable "test" with the value "lel". But the object doesn't contain _eventEnemyHP etc. So i can call $gameMap.events()[eventId].test; but not $gameMap.events()[eventId]._eventEnemyHP;

What am I doing wrong?

s0T7x
  • 69
  • 1
  • 9
  • 4
    Try to log `OBAMA!` instead. – sp00m Feb 17 '17 at 16:18
  • you sure the code is going into the if block for the same eventId you're checking afterwards? try logging that also – alebianco Feb 17 '17 at 16:19
  • 2
    Instead of stumbling around in the dark with a `console.log` torch, turn on the lights by using the fully-featured debugger built into your browser. :-) – T.J. Crowder Feb 17 '17 at 16:20
  • @alebianco iam pretty sure it does. The `eventId` is only for fetching the right data. The Object calls this function itself when initialized. – s0T7x Feb 17 '17 at 16:22
  • @T.J.Crowder could not have said it better. Don't ask me why i never used it before. Unfortunately it doesn't help me. Still the same problem. – s0T7x Feb 17 '17 at 16:25

0 Answers0