diff options
author | jacopograndi <jacopo.grandi@outlook.it> | 2021-12-24 21:11:39 +0100 |
---|---|---|
committer | jacopograndi <jacopo.grandi@outlook.it> | 2021-12-24 21:11:39 +0100 |
commit | 7cb4290601010459b09376396c7833ec391c25bf (patch) | |
tree | be6243e49ad764f90418e6d41641f99209da2b29 /scripts/saveload.gd | |
parent | e9598b88841374301646a7115253ab38ac904e4c (diff) |
working on it
Diffstat (limited to 'scripts/saveload.gd')
-rw-r--r-- | scripts/saveload.gd | 26 |
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 |