Parameter for Tracking 'i' variable

Status
Not open for further replies.

22pepperjack

Veteran
Veteran
Joined
Jun 18, 2013
Messages
235
Reaction score
72
First Language
English
Primarily Uses
so im editing the JS for a Yanfly script, and within it is the following line:

for (var i = 1; i <= 10; i++) {

this line is being used to create a dynamic list of variables to display. allowing for the list to be however big or small the user wants, however, im trying to create a Parameter that counts how many variables are currently being displayed since the number changes throughout the game. is there a line i can insert after this one that basically says "if 'i' is increased by 1, then increase this parameter by 1'? the idea being that by the end of the dynamic lists creation the parameter will be equal to the variable.

im not really asking for help with the script, just this algorithm, so i beleive this to be the right forum, if not, thank you moderator for moving it over! also, if context is needed for the algorithm, its in Yanfly's MainMenuVariable script. line 329
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,668
First Language
German
Primarily Uses
RMMV
I think you've mistaken something here.
that i is the control variable of a for-loop, which means it is always counted from 1 to 10 (in this case, starting from var i=1 and counting i++ as long as i<=10), it never goes higher than 10 and always goes up to 10 before the loop is completed.

It would help if you give a link to the specific script that you're talking about and what the for-loop does in that script.
 

22pepperjack

Veteran
Veteran
Joined
Jun 18, 2013
Messages
235
Reaction score
72
First Language
English
Primarily Uses
Oh, I thought I had it figured out lol guess not, I’m at work now but will provide a link and description when I get home later, thanks for clarifying my mistake though!
 

22pepperjack

Veteran
Veteran
Joined
Jun 18, 2013
Messages
235
Reaction score
72
First Language
English
Primarily Uses
alright, update time!

this is the link to the Yanfly script:
http://yanfly.moe/2017/07/07/yep-145-main-menu-variable-window-rpg-maker-mv/

in this script the built in adjustable parameters includes slots for up to 10 variables; making it so that at your whim you can say "hey when this switch is on, display this variable on the main menu". i'm only using 6 of the built in parameters instead of the available 10, but i need a parameter to keep track of how many variables are currently being displayed.

i see now how that "i" is being used, but im still having trouble adjusting the code to add in an extra parameter that counts how many variables are active at one time. or in this case, im looking for a way to make a parameter that says "hey, how many times is "i" being used to draw a variable?" instead of "how many variables are linked to it."

not sure if im searching in the wrong area for a solution to this, but all help is appreciated!
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
You weren't quite in the right place, it's down at line 371. Here's an example to get you started, I put comments on the lines that I added.

Code:
Window_MainMenuVariable.prototype.refresh = function() {
  var myCounter = 0; //added
  this.contents.clear();
  var x = this.textPadding();
  var y = 0;
  for (var i = 1; i <= this.maxVariables(); i++) {
    if (this.showVariableData(i)) {
      this.resetFontSettings();
      y = this.drawVariableData(i, x, y);
      myCounter += 1; //added
    }
  }
  var width = this.contents.width - this.textPadding() * 2; //added
  this.drawText(myCounter, x, y, width, 'right'); //added
};
 

22pepperjack

Veteran
Veteran
Joined
Jun 18, 2013
Messages
235
Reaction score
72
First Language
English
Primarily Uses
ok, so that part is working perfectly to display the number, thanks for the help Aloe Guvner! however, the last issue im having is in my attempt to link it back to a Parameter that i can call from an eval later on. i tried placing
"Param.MMVarCounter = mycounter;" both early on in the parameters section of the script and right before and after the above lines, i also tried a variation with "Param.MMVarCounter = var mycounter;" in the same places, but both are coming back as basically non-existant or errors as it seems to just void out and not run the script at all. didnt think parameters and variable were this hard to grasp lol, although i know what a loop function looks like in JS, had no idea thats what i was looking at before XD im more used to GML instead.

EDIT:
Nevermind i got it working, i placed the "Param.MMVarCounter" parameter up above in teh parameters section and had it equal zero, then right above the var width line down below, had it equal myCounter. thanks again guys!
 
Last edited:

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,351
Reaction score
8,532
First Language
English
Primarily Uses
RMMV

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

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top