options menu progress
This commit is contained in:
parent
904db7c6fb
commit
c083791b9a
7 changed files with 183 additions and 31 deletions
47
Data.gd
Normal file
47
Data.gd
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
extends Node
|
||||
|
||||
@export var save : SleepyclockSave
|
||||
@export var path : String = "user://sleepyclockSave.tres"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
print("looking for save...")
|
||||
if not load_data():
|
||||
print ("no save detected... creating new save")
|
||||
new_data()
|
||||
else:
|
||||
print("found it! loading now...")
|
||||
load_data()
|
||||
|
||||
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
# returns true if new data created and saved
|
||||
func new_data() -> bool:
|
||||
save = SleepyclockSave.new()
|
||||
var error = ResourceSaver.save(save,path)
|
||||
if error != OK:
|
||||
print(error)
|
||||
return false
|
||||
return true
|
||||
|
||||
# returns true if data successfully loaded into save
|
||||
func load_data() -> bool:
|
||||
if not FileAccess.file_exists(path):
|
||||
return false
|
||||
else:
|
||||
save = ResourceLoader.load(path)
|
||||
return true
|
||||
|
||||
# returns true if data successfully saved
|
||||
func save_data() -> bool:
|
||||
var error = ResourceSaver.save(save,path)
|
||||
if error != OK:
|
||||
print(error)
|
||||
return false
|
||||
return true
|
||||
Loading…
Add table
Add a link
Reference in a new issue