MENU WHIT LEVELS LOCKED

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DEKADO

Sorry for my English, I’m using the google translator.

Hi, I’m doing a platform game, which consists of 20 levels.
The logic to be able to go to the next level must collect 3 points (at the moment I call them “stars”) so pass the level, but I have not found a way to implement this, I obtained a couple of Scrips online.
These implement directories and their use but I still do not understand how to apply it for this specific case. What I understand that the directories would do in this case is to save the status of the levels, that is, which levels are locked and which are not.

Can you advise me with this?

#Script Button to select level

extends Node2D
Nivel

export (int) var level
export (String) var leveltoload
export (bool) var enabled
export (bool) var scoregoalmet
Textura

export (Texture) var blocktext
export (Texture) var opentext
export (Texture) var goalmet
export (Texture) var goalnotmet
onready var levellabel = $TextureButton/Label
onready var button = $TextureButton
onready var start = $Sprites
func ready():
if gamedata.levelinfo.has(level):
enabled = gamedata.levelinfo[level][“unlocked”]
else:
enabled = false
setup()
music.stop()
func setup():
levellabel.text = String(level)
if enabled:
button.texturenormal = opentext
else:
button.texturenormal = blocktext
levellabel.hide()
if scoregoalmet:
start.texture = goalmet
levellabel.show()
else:
start.texture = goalnotmet
func _onTextureButtonpressed():
if enabled:
gettree().changescene(levelto_load)

This script is the autoload that checks the status of the levels. As I said I saw it online in a CandyCrush style game.
That is why it says “goal” or “Score Goal” which I understand I must use to be the one to check the status of the “stars”, if all 3 have already been collected

#GAMEDATA GLOBAL VAR AUTOLOAD

extends Node

var levelinfo = {}
var defaultlevelinfo = {
1:{
“unlocked”: true,
“starsunlocked”: 0
}
}
onready var path = “user://save.dat”

func ready():
levelinfo = load_data()

func savedata():
var file = File.new()
var err = file.open(path, File.WRITE)
if err !=OK:
print (“Algo esta mal”)
return
file.storevar(level_info)
file.close()

func loaddata():
var file = File.new()
var err = file.open(path, File.READ)
if err !=OK:
return defaultlevelinfo
print(“Algo esta mal”)
var read = {}
read = file.getvar()
return read

link image: https://imagizer.imageshack.com/img923/2799/q31zL4.png