[FIXED]TypeError: Cannot read property '2' of undefined

Discussion in 'Javascript/Plugin Support' started by shneskelecta, Jul 22, 2019.

Thread Status:
Not open for further replies.
  1. shneskelecta

    shneskelecta Villager Member

    Messages:
    23
    Likes Received:
    1
    Location:
    France
    First Language:
    francais
    Primarily Uses:
    RMMV
    Hello there,
    I'm using this code on a state notag for stacking buff. It work fine but at the end of the state/battle, the stats buffed keep. The State is set up for be removed at the end of the fight.


    Code:
    <Custom Apply Effect>
    user._stack = user._stack || 0;
    user._paramUp = user._paramUp || [];
    for(i = 2; i < 6; i++){
    user._paramUp[i] = user._paramUp[i]  || (Math.round(user.param(i) * 0.25));
    if(user._stack < 2){
    user.addParam(i, user._paramUp[i]);
    }
    }
    user._stack++;
    user._stack = Math.min(user._stack, 2);
    </Custom Apply Effect>
    <Custom Remove Effect>
    user._stack = user._stack || 0;
    user._paramUp = user._paramUp || [];
    for(j = user._stack; j > 0; j--){
    for(i = 2; i < 6; i++){
    user._paramUp[i] = user._paramUp[i]  || (Math.round(user.param(i) * 0.25));
    if(j > 0){
    user.addParam(i, -user._paramsUp[i]);
    }
    }
    }
    user._stack = undefined;
    user._paramUp = undefined;
    </Custom Remove Effect>
    ----------------------------
    Code:
    TypeError: Cannot read property '2' of undefined
        at eval (eval at Game_Battler.customEffectEval (YEP_BuffsStatesCore.js:1378), <anonymous>:7:33)
        at Game_Actor.Game_Battler.customEffectEval (YEP_BuffsStatesCore.js:1378)
        at Game_Actor.Game_Battler.removeStateEffects (YEP_BuffsStatesCore.js:1411)
        at Game_Actor.Game_Battler.removeState (YEP_BuffsStatesCore.js:1405)
        at Game_Actor.Game_Battler.removeState (YEP_X_VisualStateFX.js:308)
        at Game_Actor.Game_Battler.removeState (YEP_AutoPassiveStates.js:566)
        at Game_Actor.Game_BattlerBase.updateStateTurnTiming (YEP_BattleEngineCore.js:3633)
        at Game_Actor.Game_BattlerBase.updateStateTurnTiming (YEP_BuffsStatesCore.js:1513)
        at Game_Actor.Game_BattlerBase.updateStateTurnEnd (YEP_BattleEngineCore.js:3650)
        at Game_Actor.Game_BattlerBase.updateStateTurns (YEP_BattleEngineCore.js:3610)
    ----------------------------
    Code:
     user._stack = user._stack || 0;
    user._paramUp = user._paramUp || [];
    for(j = user._stack; j > 0; j--){
    for(i = 2; i < 6; i++){
    user._paramUp[i] = user._paramUp[i]  || (Math.round(user.param(i) * 0.25));
    if(j > 0){
    user.addParam(i, -user._paramsUp[i]);
    }
    }
    }
    user._stack = undefined;
    user._paramUp = undefined;
     
    #1
  2. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,039
    Likes Received:
    645
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Code:
    if(j > 0){
      user.addParam(i, -user._paramsUp[i]);
    }
    _paramsUp isn't defined... :p
     
    #2
    shneskelecta likes this.
  3. shneskelecta

    shneskelecta Villager Member

    Messages:
    23
    Likes Received:
    1
    Location:
    France
    First Language:
    francais
    Primarily Uses:
    RMMV
    omfg how can i missed that... I passed 2 hour to try to understand why that don't work... And just for an error like that... Kill me plz... :rswt

    Thanks you by the way ! :rswt:rswt:rswt
     
    #3
  4. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,039
    Likes Received:
    645
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    It happens, don't worry. Happy RPG Making! :kaothx:
     
    #4
    shneskelecta likes this.
  5. slimmmeiske2

    slimmmeiske2 Little Red Riding Hood Moderator

    Messages:
    5,313
    Likes Received:
    3,958
    Location:
    Belgium
    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.

     
    #5
Thread Status:
Not open for further replies.

Share This Page