aboutsummaryrefslogtreecommitdiff
path: root/scripts/saveload.gd
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2021-12-24 21:11:39 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2021-12-24 21:11:39 +0100
commit7cb4290601010459b09376396c7833ec391c25bf (patch)
treebe6243e49ad764f90418e6d41641f99209da2b29 /scripts/saveload.gd
parente9598b88841374301646a7115253ab38ac904e4c (diff)
working on it
Diffstat (limited to 'scripts/saveload.gd')
-rw-r--r--scripts/saveload.gd26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/saveload.gd b/scripts/saveload.gd
new file mode 100644
index 0000000..9f7a203
--- /dev/null
+++ b/scripts/saveload.gd
@@ -0,0 +1,26 @@
+extends Node
+
+
+func load_parse_json (path):
+ var data_file = File.new()
+ if data_file.open(path, File.READ) != OK:
+ return
+ var data_text = data_file.get_as_text()
+ data_file.close()
+ var data_parse = JSON.parse(data_text)
+ if data_parse.error != OK:
+ return
+ var data = data_parse.result
+ return data
+
+func parse_dir (path : String, extension : String = ""):
+ var files = []
+ var dir = Directory.new()
+ dir.open(path)
+ dir.list_dir_begin(true)
+ var file = dir.get_next()
+ while file != "":
+ if file.ends_with(extension):
+ files.append(file)
+ file = dir.get_next()
+ return files