[Solved] Some trouble with Highscore table (b4 xmas)

Hi guys,

I´ve got some trouble with my highscore table, before xmas. :rolleyes:o_O
I programmed some objects and put them into different rooms in senseful order.
programmed a name-entry screen for it, too. Everything works, but any time I
finished the name entry in testing-mode, GMS2 says:


FATAL ERROR in
action number 1
of Key Press Event for <Enter> Key
for object oAlphabetRun:

ini_write_real argument 3 incorrect type (string) expecting a Number (YYGR)
at gml_Object_oAlphabetRun_KeyPress_13 (line 26) - ini_write_real(string(i), "SCORE", global.score_array[i, 1]);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_oAlphabetRun_KeyPress_13 (line 26)


The concerning non-sprited object has following codes:

Code:
CREATE

image_index = 0;
image_speed = 0;
if !audio_is_playing(au_HighscoreSound){
    audio_play_sound(au_HighscoreSound,1,true);
}
letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890@*?!&_+-"
position = 1;
name = "";
limit = 12;
w = room_width/2;
h = room_height/2;


STEP

if keyboard_check_pressed(vk_right){
    position += 1;
    if position>string_length(letter){
        position = 1;
    }
}

if keyboard_check_pressed(vk_left){
    position -= 1;
    if position < 1 {
        position = string_length(letter)}
}

if keyboard_check_pressed(vk_down){
    if string_length(name)<limit {
        name += string_char_at(letter, position)}
}

if keyboard_check_pressed(vk_up){
    name = string_delete(name, string_length(name), 1)}
 

DRAW

draw_set_font(Kiddybox_Font3);
draw_set_halign (fa_center);
draw_set_valign (fa_center);
draw_text(w, h+65, name);

draw_set_font(Kiddybox_Font4);
draw_set_halign (fa_center);
draw_set_valign (fa_center);
draw_text(w, h-54, string_char_at(letter, position));


KEYPRESSED ENTER

global.name = name;

ini_open("HighScoreSA.ini");
for (i = 0; i < 10; i++)
    {
        global.score_array[i, 0] = ini_read_string(string(i), "NAME", "............");
        global.score_array[i, 1] = ini_read_real(string(i), "SCORE", 0);
    }
ini_close();

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,0];}
         
            global.score_array[i, 0] = global.name;
            global.score_array[i, 1] = score;
            break;
        }
    }

ini_open("HighScoreSA.ini")
for (i = 0; i < 10; i++){
    ini_write_string(string(i), "NAME", global.score_array[i, 0]);
    ini_write_real(string(i), "SCORE", global.score_array[i, 1]);
}
ini_close();

room_goto(Highscore);

As you can see, the previously described error report is coming from
ini_write_string(string(i), "NAME", global.score_array[i, 0]);
ini_write_real(string(i), "SCORE", global.score_array[i, 1]);

within the keypressed enter-block. Can anybody see what I can´t see becuz of
my business blindness? :eek::cool: Ghaa!!!


If we don´t communicate until Santa´s Rising, I wish you all a peacefull
and fat...


. . . . . . . . . . . . . .
. . . . . . . . . . . . .
MERRY X-MAS!

Archie.
 

DarthTenebris

Definitely not a Sith Lord
Have you tried to print out global.score_array[i, 1] and see what it contains? Additionally, you can try to use real() to convert the variable to a number, if the issue is simply that the variable contains the value as a string.

Hope I helped :)
 
]Hi Darth.

Thank you for remarking me. :)
Meanwhile I´ve found out, where the problem was.

Here was the problem:

[...]
global.score_array[j, 1] = global.score_array[j-1,0];} // it has to be 1
[...]

and additionally in the highscore-room there in the DRAW-code I forgot to put the vertical replacement/exchange
of the names with inserting:

[...]
yy += 45; //spacing between the lines of the Top-10-list.
[...]

Now it works fine!
It was a simple problem, but I couldn´t see it.
Sometimes it helps for having a clear eye with making nothing,
doing quite other things. *sigh*

Hope you had a beautiful xmas-time!?
Happy new year! :D
Archie.
 
Top