Leaderboard/Score board

mpurnell

Veteran
Veteran
Joined
Dec 6, 2015
Messages
82
Reaction score
10
First Language
english
Primarily Uses
Cant say my attempt at array's are the best, but pretty much trying to get like a soccer/sports score board going.
8 teams, first 8 variables for the teams, bottom variables to put the in order, but im lost on how to convert this to rpg maker mv so i can put them in order or howd i get that... lets say variable 467 ended up first and how i would establish that and then the next 7 in order.

var Na = [$gameVariables.value(461), $gameVariables.value(464), $gameVariables.value(467), $gameVariables.value(470), $gameVariables.value(473), $gameVariables.value(476), $gameVariables.value(479), $gameVariables.value(482)];

Na.sort(function(a,d){return a < d});

var variable_names = {};

for(var i = 0; i< Na.length; i++){

variable_names['na_'+i] = Na;

}

//console.log(variable_names);

$gameVariables.setValue(397, variable_names.na_0);

$gameVariables.setValue(398, variable_names.na_1);

$gameVariables.setValue(399, variable_names.na_2);

$gameVariables.setValue(400, variable_names.na_3);


Thanks
 
Last edited:

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Where exactly are you lost? It's pretty much right so far.

variable_names['na_'+i] = Na;
This line doesn't look right, you are setting each property of the object as the entire array (instead of a single value of the array).

Is there a reason that you are converting the sorted array data into an object rather than leaving it as an array?
 

mpurnell

Veteran
Veteran
Joined
Dec 6, 2015
Messages
82
Reaction score
10
First Language
english
Primarily Uses
Yea i was doing that because i was tryinf to find the easiest way to pull up every result so i couod set as another variable. Then hit another hurdle and my brain just melted on what i was trying to accomplish lol
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
No problem haha, I have been in the 'brain melted' mode many times myself.

I was wondering because objects can be very useful to hold the data if it is complex/different kinds of data. Like if you wanted an object for the whole scoreboard with all the top 8 teams & the top 3 keepers & top 3 goal scorers & last year's champion & location of the match, etc. etc.
I think you get my meaning of how an object can be useful for more complex data maintenance.

Here's the slight edit which should get your original code working.
Code:
var Na = [$gameVariables.value(461), $gameVariables.value(464), $gameVariables.value(467), $gameVariables.value(470), $gameVariables.value(473), $gameVariables.value(476), $gameVariables.value(479), $gameVariables.value(482)];
Na.sort(function(a,d){return a < d});
var variable_names = {};
for(var i = 0; i< Na.length; i++){
    variable_names['na_'+i] = Na[i];
}
//console.log(variable_names);
$gameVariables.setValue(397, variable_names.na_0);
$gameVariables.setValue(398, variable_names.na_1);
$gameVariables.setValue(399, variable_names.na_2);
$gameVariables.setValue(400, variable_names.na_3);
If you don't need the complexity of the object, then you could leave it as an array. The bottom part would just be:

Code:
$gameVariables.setValue(397, Na[0]);
$gameVariables.setValue(398, Na[1]);
$gameVariables.setValue(399, Na[2]);
$gameVariables.setValue(400, Na[3]);
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
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

Forum statistics

Threads
105,857
Messages
1,017,015
Members
137,563
Latest member
MinyakaAeon
Top