Skipping Parameters in the Array

I already know that
for (var i = 0; i < 8; ++i) {
Will draw the parameters but what if I want to skip one like MMP?

I think it's something like:
if (i === 2) continue {

I tried the above code but it crashes my test play.
I already know that
Will draw the parameters but what if I want to skip one like MMP?

I think it's something like:


I tried the above code but it crashes my test play.

for(var i = 0 ; i < 8 ; ++i) {
if (i==2) {//do nothing}
else {
//do something
}}
PHP:
for(var i = 0 ; i < 8 ; ++i) {
 if (i===2) { continue; } // jump to next iteration
}

https://www.w3schools.com/jsref/jsref_continue.asp
@Jonforum I knew it was something like that. If you don't mind, there's the gap in its space. How would I remove that?
@Jonforum I knew it was something like that. If you don't mind, there's the gap in its space. How would I remove that?
am not sure i understand !!
But if you want remove space or gaps.
http://jsbeautifier.org/
The line spacing is based on the iterator 'i' which is still increased even when it doesn't draw the parameter. You could introduce another iterator, only increase that when a parameter is drawn, and base the line spacing off that iterator.
I've tried using:
if (i===1) {
this.lineHeight = this.lineHeight * 2;
}

But it doesn't seem to work. Basically want to get "1" which is MHP in the space of "2."

I've also tried this one:
if (index === 1) {
this.drawText (text, x, y*2, this._paramNameWidth); }
And it won't show up at all.
Did you try creating a new iterator like I suggested?

We can give more specific help, if you would like that, please post the whole code so we know what edits you've made so far.
Window_VictoryLevelUp.prototype.itemRect = function(index) {
var rect = new Rectangle();
rect.x = Yanfly.Param.ALUSkillWidth + this.standardPadding() * 2;
if (i===1){
rect.y = (this.lineHeight() * 4)}
else{
rect.y = index * this.lineHeight() - this.lineHeight();
}
rect.width = this.contents.width;
rect.width -= this.widthArea();
rect.height = this.lineHeight();
return rect;
};
Here's what I have.
I'm confused, you were asking for help about a 'for' loop earlier, where is that?

And how exactly do you want to remove that space, you want to move everything up one line, or you want to distribute the space evenly between all of the lines?
Move everything up one line. Also was trying to do the I===1 bit separately
Understood, but my suggestion was to use another iterator in the 'for' loop. If you would like me to explain more about this suggestion, then I need to see the 'for' loop.

What you posted is a function of Window_VictoryLevelUp, which is not a window in the standard RMMV code, and you didn't share what plugin it is from. Also, that function has an input parameter 'index', and I can't see where that function is called or what the input is. Due to these things, I can only guess at what it is doing, but my guess isn't good enough to help you in the best way possible, so I need more information.
for (var i = 1){
var rect = this.itemRect(i);
this.drawRightArrow(rect);
this.drawParamName(i, rect);
this.drawCurrentParam(i, rect);
this.drawNewParam(i, rect);
}
for (var i = 3; i < 8; ++i) { //Draws arrays.
if (i===2) {continue} //Skips MMP
var rect = this.itemRect(i);
this.drawRightArrow(rect);
this.drawParamName(i, rect);
this.drawCurrentParam(i, rect);
this.drawNewParam(i, rect);
// this.drawParamDifference(i, rect); In this case it would hide the sum of the new stats.
}
};
Code:
for (var i = 1){
var rect = this.itemRect(i);
this.drawRightArrow(rect);
this.drawParamName(i, rect);
this.drawCurrentParam(i, rect);
this.drawNewParam(i, rect);
}
This isn't correct syntax for a 'for' loop, this is going to cause a syntax error, I would suggest that you check out the documentation on 'for' loops.

Code:
for (var i = 3; i < 8; ++i) { //Draws arrays.
if (i===2) {continue} //Skips MMP
var rect = this.itemRect(i);
this.drawRightArrow(rect);
this.drawParamName(i, rect);
this.drawCurrentParam(i, rect);
this.drawNewParam(i, rect);
// this.drawParamDifference(i, rect); In this case it would hide the sum of the new stats.
}
And this 'for' loop starts at 3 already, so the 'if' statement for i===2 doesn't do anything.

Anyways, I can suggest something now. Since the 'for' loop you shared includes 4 functions that are modified from the standard RMMV code and you didn't share what those functions are, I can't guarantee what they do (although I can guess). And since you didn't share the code which displays the player's level, I can't suggest anything for that.

There are two ways you can do this:

1. Loop through all the parameters, using 'continue' on the ones not to show, and using another iterator to track the line

Suggestion/template:
Code:
var line = 0;
for (var i = 0; i < 8; i++) { 
if (i===1) {continue} //Skips MMP
var rect = this.itemRect(line);
this.drawRightArrow(rect);
this.drawParamName(i, rect);
this.drawCurrentParam(i, rect);
this.drawNewParam(i, rect);
line++;
}

2. Define a list of exactly which parameters you want to show

Suggestion/template:
Code:
var paramsToShow = [0, 2, 3, 4, 5, 6, 7]; //Shows all but MMP
// 0 = MHP
// 1 = MMP
// 2 = ATK
// 3 = DEF
// 4 = MAT
// 5 = MDF
// 6 = AGI
// 7 = LUK
for (var i = 0; i < paramsToShow.length; i++) { 
var rect = this.itemRect(i);
this.drawRightArrow(rect);
this.drawParamName(paramsToShow[i], rect);
this.drawCurrentParam(paramsToShow[i], rect);
this.drawNewParam(paramsToShow[i], rect);
}
That second one did the trick. Probably just worded it wrong. Thanks!

And Level Up Aftermath requires you to add an extra number to your numbers since "0" is the level which I removed since it was redundant.

But Equip Core is a different story...

Original thread: https://forums.rpgmakerweb.com/threads/skipping-parameters-in-the-array.91409/