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

Status
Not open for further replies.

shneskelecta

Villager
Member
Joined
Jan 5, 2017
Messages
23
Reaction score
1
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;
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,560
Reaction score
1,033
First Language
EN
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;
Code:
if(j > 0){
  user.addParam(i, -user._paramsUp[i]);
}
_paramsUp isn't defined... :p
 

shneskelecta

Villager
Member
Joined
Jan 5, 2017
Messages
23
Reaction score
1
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
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,512
Reaction score
4,418
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.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Hi, there.
I'm Creta Park, as Software engineer and Indie game developer.

Profile : creft.me/cretapark
GitHub : github.com/creta5164
Blog : creta5164.tumblr.com


My stuff

Who shares/sells their scripts/plugins on itch.io? Can I pick your brain?
If you ever need fantasy names and you're bored, make a fictional alphabet. Switch around the letters and see what you get :p
I JUST GOT PROMOTED TO 9TH GRADE BOIS!

Forum statistics

Threads
98,171
Messages
949,977
Members
129,462
Latest member
Sarry123
Top