L
Linkruler
Guest
Before I get too far, I followed this tutorial to get this code.
So I've been working a couple of days now to make a working leaderboard. Not knowing of a reliable way to make this, I followed slasher's tutorial on making a leaderboard. After following all of the steps, the system does not work still, and I am not sure why.
Let me explain my current setup. When the player gets a game over in-game, they will be taken to a continue screen. If they select no to continue or let the timer run out, then it brings up another game over screen. From here, they have to push the jump button to proceed, where it will ask for their name (which uses a get_string_async command). From there it follows the async dialogue command below:
From here, things seem to not work. For one, it ignores all of the code inside the if (score >= global.score_array[i, 1]) brackets. I tested the different sections by playing a sound at different sequences.
Concerning other parts of this system, I currently don't have it loading the data at the start, since I'm not exactly sure what to write. This is the code I have at bootup to initialize the variables:
The data in the .ini will read after going through the async dialogue, but I'm not sure why I can't get it to run beforehand (I tried to set the same commands in the boot room's creation code and it errored out saying that it was not an array)
If you have need for any other code, feel free to ask
So I've been working a couple of days now to make a working leaderboard. Not knowing of a reliable way to make this, I followed slasher's tutorial on making a leaderboard. After following all of the steps, the system does not work still, and I am not sure why.
Let me explain my current setup. When the player gets a game over in-game, they will be taken to a continue screen. If they select no to continue or let the timer run out, then it brings up another game over screen. From here, they have to push the jump button to proceed, where it will ask for their name (which uses a get_string_async command). From there it follows the async dialogue command below:
Code:
var i_d = ds_map_find_value(async_load, "id")
if i_d == name
{
if ds_map_find_value(async_load, "status") //user selecting ok
{
if ds_map_find_value(async_load, "result") != "" //name not blank
{
global.name = ds_map_find_value(async_load, "result") //get the name entered
//open ini file
ini_open("config.ini")
for (i = 0; i<10; i++)
{
global.score_array[i,0] = ini_read_string(string(i), "Name", "unknown")
global.score_array[i,1] = ini_read_string(string(i), "Score", "0")
global.score_array[i,2] = ini_read_string(string(i), "Completion", "incomplete")
}
ini_close()
//find first spot where player's score is greater
for (i = 0; i < 10; i++)
{
if (score >= global.score_array[i, 1])
{
for (j = 9; j>i; j--)
{
global.score_array[j,0] = global.score_array[j-1,0];
global.score_array[j,1] = global.score_array[j-1,1];
global.score_array[j,2] = global.score_array[j-1,2];
}
global.score_array[i,0] = global.name;
global.score_array[i,1] = score;
global.score_array[i,2] = global.completion;
break;
}
}
ini_open("config.ini")
for(i=0; i<10; i++)
{
ini_write_string(string(i), "Name", global.score_array[i,0]);
ini_write_string(string(i), "Score", global.score_array[i,1]);
ini_write_string(string(i), "Completion", global.score_array[i,2]);
}
ini_close()
room_goto(rm_menu1)
}
}
}
Concerning other parts of this system, I currently don't have it loading the data at the start, since I'm not exactly sure what to write. This is the code I have at bootup to initialize the variables:
Code:
//Load scores and name for leaderboard
ini_open("config.ini")
for (i = 0; i < 10; i++)
{
global.score_array[i,0] = "Name"
global.score_array[i,1] = 0
global.score_array[i,2] = "incomplete"
}
ini_close()
If you have need for any other code, feel free to ask