• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [Resolved] Ini File Default Values Problem

Hi there, I'm having some problems getting the default values of my high score table to show up. I've added a file to 'included files' that I want to be the default values, basically a list of scores to beat - it looks like this...

Code:
[0]
Name=“SSS”
Score=“50000.000000"
[1]
Name=“AAA”
Score=“45000.000000"

.....etc

[9]
Name=“ZZZ”
Score=“5000.000000"
It grabs the names ok but the scores always display as 0 for some reason. Any idea why it's ignoring the scores and always making them 0? Everything is also working fine otherwise, when the player inputs their own scores, but I'd really like to have these fake scores initially. I'd be grateful for any pointers

This is in my boot room
Code:
ini_open("highScoreTable");
for (i = 0; i < 10; i++){
    global.score_array[i,0] = ini_read_string(string(i),"Name","AAA");
    global.score_array[i,1] = ini_read_real(string(i),"Score",0);
}
ini_close();
and then this is in the high score room where they're displayed
Code:
//create
ini_open("highScoreTable");
for (i = 0; i < 10; i++){
    global.score_array[i,0] = ini_read_string(string(i),"Name","GRR");
    global.score_array[i,1] = ini_read_real(string(i),"Score",0);
}
ini_close();

//draw
for (i = 0; i < 10; i++){
//names
draw_text_transformed(xx,yy,string(global.score_array[i,0]),highScoreScale,highScoreScale,0);
//scores
 draw_text_transformed(xx,yy,string(global.score_array[i,1]),highScoreScale,highScoreScale,0);
}
Thanks,
Graeme
 
I believe it's because you're confusing your score variable. You've saved it as a string in the ini, then tried to read a real, and asked it to convert the saved string into a string.

Why not save the score as a real in the first place (get rid of speech marks) and just read the real (i).
 
Thanks Michael, sorry I don't really understand tho - I thought the "Score" in global.score_array[i,1] = ini_read_real(string(i),"Score",0) relates to the Key in the ini file, not the score variable - I don't have variables called "Score" or "Name", but it reads the names fine. There are no actual player scores to read at this point as it's for when you first play the game.

When I change it to ini_read_string(string(i),"Score",0) it does give me the scores but with the 6 decimal places after them.

if I do ini_read_real(real(i),"Score",0) it just gives me 0's.
 
I'm trying to add a bunch of default scores to the scoreboard for the player to beat before they can add their own. They're in an ini file called
'highScoreTable' which I've added as an 'Included File' to the game - that's what I'm trying to get it to read. It gets the names ok, but not the scores.

This is the 'highScoreTable' file
Code:
[0]
Name=“SSS”
Score=“50000.000000"
[1]
Name=“AAA”
Score=“45000.000000"

.....etc

[9]
Name=“ZZZ”
Score=“5000.000000"
 
Sorry, I replied quickly on my phone and brain farted a bit. What I think you're trying to do is read the fake scores you set in your ini before starting. If you remove the speech marks as below, does this not work?

Code:
[0]
Name=“SSS”
Score=50000.000000
[1]
Name=“AAA”
Score=45000.000000

.....etc

[9]
Name=“ZZZ”
Score=5000.000000
 

Xer0botXer0

Senpai
I cant see why it shouldn't work, your ini information in the ini file appears correct, and the manner in which you load the information into a 2D array seems fine too.
 
I cant see why it shouldn't work, your ini information in the ini file appears correct, and the manner in which you load the information into a 2D array seems fine too.
Yeah, turns out it was what Michael suggested, just needed to take off the quotation marks around the scores in the included file. Thanks!
Graeme
 

Xer0botXer0

Senpai
That's odd because my ini file has scores surrounding numeric values and don't have that problem. Must be GMS2.0 thing.
 
Top