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
36,278
Reaction score
9,702
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,159
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
16,621
Reaction score
9,217
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.

Latest Threads

Latest Posts

Latest Profile Posts

ScreenShot_6_28_2022_3_2_40.png

There's 7 main areas in the game that are all connected. This train get's you from an underground lab to the center of someone's subconscious. inside the train you can talk to some of the passengers. but going to the top of it, there's battles.
Speedrunning all character portraits just so they all have the same quality. Not sure if this was a good idea, but now I'm almost done.
We now have a gameplay video!
DrBuni wrote on Akiritas's profile.
That is a cute Link picture, reminds me of the Samurai Jack artstyle.
I had an idea on how to get my encounters to leash after chasing the player for a little bit. After going down the Javascript rabbit hole, I realized I could do it in a regular movement route. Derp!

Forum statistics

Threads
123,145
Messages
1,154,371
Members
161,488
Latest member
rybaspi
Top