r3-next/load.gd

25 lines
943 B
GDScript3
Raw Normal View History

2023-11-01 17:35:54 +01:00
extends Node
2024-10-29 22:37:39 +01:00
var file = File.new()
2023-11-01 17:35:54 +01:00
func _init():
2024-10-29 22:37:39 +01:00
if file.file_exists(Global.hiscoresfile):
2023-11-23 20:19:21 +01:00
Global.firstrun = false
2024-10-29 22:37:39 +01:00
file.open(Global.hiscoresfile, File.READ)
Global.levelmax = file.get_as_text().rsplit(",", true, 9)
2023-11-01 17:35:54 +01:00
# We need to revert the game state so we're not cloning objects
# during loading. This will vary wildly depending on the needs of a
# project, so take care with this step.
# For our example, we will accomplish this by deleting saveable objects.
#var save_nodes = get_tree().get_nodes_in_group("Persist")
#for i in save_nodes:
# i.queue_free()
# Load the file line by line and process that dictionary to restore
# the object it represents.
else:
2023-11-23 20:19:21 +01:00
Global.firstrun = true
2024-10-29 22:37:39 +01:00
var saveinit = "9999999,9999999,9999999,9999999,9999999,9999999,9999999,9999999,9999999"
var file = File.new()
file.open(Global.hiscoresfile, File.WRITE)
2023-11-01 17:35:54 +01:00
file.store_string(saveinit)
2024-10-29 22:37:39 +01:00
Global.levelmax = saveinit.rsplit(",", true, 9)