Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 20, 2024, 02:21:27 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)How to save a high score and reset levels?
Pages: [1]
Print
Author Topic: How to save a high score and reset levels?  (Read 884 times)
St0rmSlaSh
Level 0
*


St0rmSlaSh


View Profile
« on: March 13, 2017, 02:23:44 PM »

Hello, everyone. I am currently developing a game which includes a high score table and if the player dies, or they complete the game, then they have a choice to input their scores. But I ran into some errors and bugs where after the player submits their scores, the level system still places a variable to where the player has unlocked the final level (If they completed the game) and of they try to go into a level, then they either automatically complete it, or they instantly die. So what I was wondering if there is a way I could reset those rooms after the player submits their scores, so that when the player does enter that information, then they can start the game fresh again. Thanks everyone!
Logged
kerempooh
Level 0
*



View Profile
« Reply #1 on: March 17, 2017, 09:50:16 AM »

Hmm... could you be more precise?

The way I understand it your problem is that you have your rooms set to "persistent" and you'd like them reset? In that case you can use room_set_persistent to reset the rooms that need resetting after the game is completed.
(I'm still trying to understand what saving high scores has to do with it...)
« Last Edit: March 17, 2017, 10:28:56 AM by kerempooh » Logged

St0rmSlaSh
Level 0
*


St0rmSlaSh


View Profile
« Reply #2 on: March 17, 2017, 03:51:15 PM »

When you complete a level, it asks you for your name and it records it. I just want to know how I can reset the persistent room after the object for the high score takes you back to the title screen.
Logged
kerempooh
Level 0
*



View Profile
« Reply #3 on: March 18, 2017, 08:29:31 AM »

Hmm... it seems the problem is a bit knottier than that...

Room_set_persistent doesn't seem to work on rooms already visited so it is not possible to "reset" them all cleanly from one convenient spot. However, here's this thread:

https://forum.yoyogames.com/index.php?threads/how-can-you-reset-mutiple-persistent-rooms.13809/

Some good ideas there, particularly that you should avoid room persistence and set up your own gamestate save system.. but as you seem to be a long way into development to redo everything, this method might help:

Quote
create a persistent controller object and put the below code in the room start event. then go to the first room.

if room_exists(room_next(room)) {room_persistent = false; room_goto_next();} else {room_goto(start_room); instance_destroy();} 
Logged

St0rmSlaSh
Level 0
*


St0rmSlaSh


View Profile
« Reply #4 on: March 19, 2017, 03:56:11 PM »

Okay, thank you! I did a bit of experimenting overnight and I found out that highscore_add saves your score even if you close the game. So, I just restarted the whole game so all the rooms reset, which is what basically happens when a player dies in a game Tongue
Logged
BomberTREE
Level 9
****



View Profile
« Reply #5 on: March 22, 2017, 04:19:38 PM »

If you ever feel like saving and loading information with a file  Hand Thumbs Up Right
https://docs.yoyogames.com/source/dadiospice/002_reference/file%20handling/ini%20files/index.html
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic