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

Look again. It writes the global variable all_level_times to storage group level_times, and reads from storage group level_times :


Then you’ve missed a step, or applied a step incorrectly.

Remember to use the debugger to confirm the variables (global and scene) hold the values you expect. And use the crtl + shift + i when the game is running to see what is being saved.

If it’s not getting saved, then the issue is at or before the write command, and you’ll need to confirm the structure has the data in it. If this hasn’t, then the issue lies in the adding the variable to the structure.

I see where you’ve gone wrong. You’ve got this :

whereas I’ve got :

You’re reading from completely the wrong storage and group…

I believe I have it right now (though I am obviously bad at that), but it’s still not working, so I probably still have something wrong. Here’s what shows up on the “you won” screen after playing a level.

I have to admit, I lolled :grin:

The value on storage is incorrect. It should look like :
image

Can you delete that entry from storage (just delete the key), and try again?

I’ve noticed a mistake in one of my step screen shot. Apologies for this. In step 6, this :

should have curr_level = GlobalVariable(current_playing_level).

This is probably causing an issue too.

I updated what you just pointed out, but I’m still getting the same readout in that “key” as in the screen grab I uploaded.

Here’s the events for the first part of the “you won” screen:

Here’s one reason why you won’t be getting the previous time :

image

The global variable is all_level_times.

Can you run the game via the debugger, and screen shot the contents of all_level_times?

This is all reminding me of the time I tried to make ice in the microwave. :joy: :sob:

I do have some neuro atypical issues that are probably not doing me any favors. I seem to have flipped where some of these things go. I fixed what you showed about the global variable being all_level_times, but I’m still getting the exact same as my last screen shot of the key.

That value component says to me that a value is being written to storage, not a text (in my screen shot a few posts back it has “str”, not “value”). Can you check the write to storage and confirm it’s correct?

It was value. Crap! OK. Fixed that, here is what shows up now.

This means the value isn’t being put into the global structure.

And here’s the problem -

There’s a typo in the first action - you’ve got GlabalVariableString, you want GlobalVariableString

I typed it out because I couldn’t figure out how to find it since search didn’t yield it. I’m really bad with typos.

Now I fixed it, and I’m definitely getting some results, but am confused by the results. Even after clearing the key, it will say that one second is my best time. Also, it doesn’t display the best time at all if I get a slower time than the last round.

Ok, I’ve made some changes to fix this. Modify the “you won” scene’s events to :

Changes to note :

  • Setting of scene variable prev_time has moved.
  • a new first subevent (subevent #1)
  • the event dealing with “the current time is better than previous time” has moved as a subevent of subevent # 1

I am really confused. Hopefully I followed what you did, but it’s still not acting the way I want it to.

I want to see text with the current level’s time, and text that shows the best time the player has had on that level if they’ve played it before. I don’t want anything to say “current time” or “previous time”.

To you does “current time” mean the time for the most recent round, and “previous time” mean the best time ever played on that level?

Yes. My object CurrentTime is your object named Timer, and my object PreviousBestTime is your object named bestTime.

Post a screen shot and we’ll sort it out.

It’s worse now. The most recent level time isn’t showing up at all, and the best time is just reading zeros.

And this is what happens after each round:

So, that means that there’s something not right with the part that sets the text for the current time.

And if you look at the action that set the text:

you’ll see that you’ve got GLobal (with an incorrect capital first L), which should be Global.

If you click on that in the editor, the text will be red, indicating it’s not right.


Also, this

is not what I posted, and makes no sense. How can you have a previous best time if it’s the very first run and no previous time exists?

What I had is

OK. I fixed that capital “L”, and found another line in which I put a capital when I shouldn’t have. I’m going to need to really stay on top of checking for that sort of thing.

I copied exactly what you have for the last bit now. (I think)

Still not working though. As little as I understand coding, I tried to figure out what is going on. Is it supposed to hide the text that shows the actual best time if there isn’t one yet, and replace it with the text object that has “Best time: 00:00”?

It seems like when it shows the text object for bestTime, there is nothing to change the text of the text object “bestTime” to actually show the best time so far. Which would make sense based on the results when running the program.

I appreciate that you have spent so much time helping, especially after I pointed out that I am in way over my head. I feel like I am starting to understand some of what you are explaining.


This should be current_level, not current_playing_level (the latter is a global variable)

Not really. It does hide or show the “New Best Time!” message depending on whether it is a better time than previously (the subevent of the subevent) or if there’s no previous time (the inverted condition event)

The events check if a previous time exists, and set the previous best time text to that if it does.

If a previous time doesn’t exist, then previous best time text is set to “Best time: 00:00”.


That’s what the forums are for. And it’s great that you’re starting to understand what it’s doing :smiley: