[Solved] Show total time at end of level on "You Won" screen?

I don’t want to display all the level times at the same time. Is that what you mean here:

I just want to show the best time for the previous level when the player beats that level.

Yes, I was thinking in cases like displaying them on a level selection screen, or a best times screen.

But if you don’t wan to do that, then following @UlisesFreitas will be less difficult. As you’re not familiar with variables, throwing global structures at you is a jump in the deep end.

I’m already mentally feeling like I’m way under the water in the deep end, so yeah… :frowning:

At one point I had it working but not formatted correctly, and now I don’t even remember how I had it working at all.

It’s a rabbit hole :slight_smile:

It was working, but just for that level. As soon as you changed scene, the time was lost.

What you essentially want to do is store the time, and recall it when needed, independent of the scene that requires it, formatting it using timeformatter::SecondsToHHMMSS(...).

Here is what I have for the playing scene I want to keep track of the time for.

timer part1
The above is in the “at beginning of scene”.

Then once the completion of the game play is concluded I have the following:

timer part1b

And then for the “you won” scene that I want to show the finished time of the previous level:

Right now nothing shows up where the time should show up on the “you won” scene.
And I still need to understand how to have on that same screen, a "Your best time: " as well.

If you don’t mind helping me a bit more, can you please explain what I’m doing wrong, using the names I’m using or I’m going to keep being confused.

You’re writing to storage named “save”, but reading from storage named “time_level_1”.

I tried switching them, but it still didn’t work.

Have you run your game to the point where you complete a level and got the “you won” scene up?

Because if you haven’t run it through yet, and there is no time saved for level 1, then when you read it in it’ll be empty, and GDevelop will use 0 as the default.

If you have run it through and completed the level, can you start the game again, and then press ctrl + shift+ i, and click on the Applications tab of the panel that appears from the right. There should be an entry under the Key column named “GDJS_save”. What is the value of it (or provide a screen shot of it)?

Yes.

I couldn’t find a column labeled “Key”.

Expand local storage (that’s roughly in the middle of your screen shot) and click on "file:// "

(I forgot to include in the instructions before because mine defaults to that)

GDJS_ just shows {}

I assume that means It’s not saving correctly

I should maybe be more specific - is that since you’ve changed the events to save to storage “save”?

And what are the events around the level complete where you save to storage? Can you screen shot it?

Yes.

When you write to storage, are you writing a value or a text? It should be value. You’ll need to double click on the “write to storage” event action to see which one it is.

It is saving to value and in the “you win” scene it is reading value.

I’m really perplexed. I’ve created a sample project that works fine, using the same storage write & read actions, using the time formatter and changing scenes.

Could you delete the storage data from application file:// and try again?

If that still fails, could you zip up the project (with graphics - it’s hard to run the game without them) and share it. PM if needed. We’ll have a look at it and see if it can be sorted out.

Do I delete that from within GDevelop?

I just tried hitting “clear” within the applications window, then played the level again. This time it popped up a result in that window, but still did not write to the screen. Here’s the screen grab.

Hmmm. I’m at a loss.

Do you want to zip up the project (with graphics - it’s hard to run the game without them) and share it? PM if needed.

Would you mind posting screen shots of your sample project commands? Maybe I can figure it out from looking at what you did?

Here’s what I have :

This code is almost identical to that in “New scene2”, except that it changes to scene “New scene”.

Both scenes have a text object that displays the retrieved storage value.

And after 10 seconds, I click the button and the next scene looks like :