- Edited
I tried to make a download and save in Godo4
Did in this lesson for Godo3.x:
https://gdscript.com/solutions/how-to-save-and-load-godot-game-data/
Script 1
extends Resource
class_name GlobaDataSave
@export var player_name = "Unit"
@export var score = 234
@export var level = 11
Script 2
extends Node
# Save and Load
var gameSave
func _ready():
# Create an instance of the class
gameSave = GlobaDataSave.new()
# Output the default value
print(gameSave.player_name)
print(str(gameSave.score))
# Change the value in gameSave
gameSave.player_name = "Alex"
# Save the file with the new value
var result = ResourceSaver.save(gameSave, "user://save.tres",ResourceSaver.FLAG_COMPRESS)
assert(result == OK)
# Checking for Save ????????????????
func load_data(save):
if ResourceLoader.exists("user://", "save.tres"):
# Output a new value
print(gameSave.player_name)
print(str(gameSave.score))
How do I create a check for and load a save file ????