extends Node @export var save : SleepyclockSave @export var path : String = "user://sleepyclockSave.tres" enum Position { Bottom, Right, Top, Left, } # 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 screen_size : Vector2i = DisplayServer.screen_get_size() # get current screen size if screen_size.x > 2560 or screen_size.y > 1440: save.size = 20 if OS.has_feature("macos"): save.position = Data.Position.Right 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,"",ResourceLoader.CACHE_MODE_IGNORE) 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