Get Name to Save for High Score Array?

0 favourites
From the Asset Store
Match the similar cards with each other and free all animals!
  • Hello,

    I followed a tutorial on YT that allows you to have a top 10 list for scores. During the tutorial it shows how you can have multiple integers listed and this works great! BUT I have a player_name txt variable that allows a player to enter their name at the beginning of the game. When the game ends I get the score, correct answers and the name to display correctly. The name stays in there until I restart the game...at that point the score and correct answers remain listed but the name has vanished.

    I am sure it is because I have a action that is changing the value of the array to an int...but this is how it was done in the tutorial and I am not sure what else to do.

    Examples

    Thanks for any assistance,

    Rich

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Looks like the global variable is only saving scores? Where was your attempt to save the names added because I can't work it out.

  • I thought that under "Check_Scores_Addition" group that line 6-9 was doing this? The section where it says "Array_LB_Addition.CurX*3...." on line 7 is supposed to be it from the tutorial.

    If I do not have X*3 then it would only save the 1st X in the Array

    If I do X*2 then it does 2 ros of X

    3 = 3 rows of X

    My Array is 3 X deep, 1 Y

    Or at least that is how I understood it in the tutorial. And it saves both the score and the correct answers that are stored in the array...but not the name...which is probably because it is not an int?

  • Apprecieate you looking into this.

    Here is the tutorial i originally followed. He only has number values...no Text.

    youtu.be/PqaX6wtxmQ8

  • It's a bit confusing to me because you're loading into the array from local storage at different rows of X over one Y but when you add the new data you are adding to one row of X over several Y yet somehow it still works for the score and answers I dunno, better if the file shared.

  • I dunno it made sense in the tutorial but I an obviously fairly new to Arrays :) My capx has a lot more than just the leader board at this point. Is it possible to share just the LB layout or is it all or nothing?

    Should I do 1 row X and 3 rows y?

  • I guess you need it all to set a score etc If you don't want to share it publicly then I am on discord (ant#4434), you could share with me there and I can try and debug the issue.

  • I changed the player_name variable to a number and if I enter in a number then that column does save. So it has to be how that command not being able to save a string value...hmmmm

    Can I add an additional command to just update the x.3(or whatever it would be called) to store a text to work with the previous line 7 command?>

  • Ah yeah I see you're forcing it to an int in event 7 which won't work for text, it'll end up as NaN. You'll have to find a way to split out the name entries separate from the scores, or you could probably do something like once the array is filled, run through all X=0 and X=1 and convert them to int, while leaving out the int part on event 7.

  • I removed the int conversion a couple weeks back and it does store the text but then the sorting for the score is all out of whack

    800 would be ranked higher than 1800 because the 1st character 8 in 800 is larger than the first character of 1 in 1800.

    Is there a way to remove the int sort so the text and scores save but then do some sort of sort of X at (0,0)?

  • That's what I mentioned above. You need to fill the array with text, so remove the int which you have done. Then convert the scores back into ints further down. Use array conditions to run through X at 0 and 1 and convert them all to int(curvalue).

  • ok I'll need to look into it as I am to sure how to do it :) Thanks for the guidance thus far. Much appreciated/

  • Tried a couple things but cannot get it to convert back, does the array have to be completely full before i can sort/connvert? Can you provide an example?

  • Now that I think about it some more you might not have to convert them to int, should just display fine as they are in the array? You just need to put the text logic separately without the int.

  • I removed the int convert in line 7 and it saves the text now but the score is not sorting correctly. I tried adding a sort to X...but maybe I added it to the wrong spot?

    Nah didn't work...i cant imagine this is as hard as I am making it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)