mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Created a basic Lobby system, to further test networking features
This commit is contained in:
29
Phase2/Networking/Client/Save/Save.gd
Normal file
29
Phase2/Networking/Client/Save/Save.gd
Normal file
@ -0,0 +1,29 @@
|
||||
extends Node
|
||||
|
||||
|
||||
const save_file = "user://save_file.json"
|
||||
|
||||
var save_data = {}
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
save_data = get_data()
|
||||
|
||||
func get_data():
|
||||
var file = File.new()
|
||||
|
||||
if not file.file_exists(save_file):
|
||||
save_data = {"player_name": "Unnamed"}
|
||||
save_game()
|
||||
file.open(save_file, File.READ)
|
||||
var content = file.get_as_text()
|
||||
var data = parse_json(content)
|
||||
save_data = data
|
||||
file.close()
|
||||
return(data)
|
||||
|
||||
func save_game():
|
||||
var save_game = File.new()
|
||||
save_game.open(save_file, File.WRITE)
|
||||
save_game.store_line(to_json(save_data))
|
Reference in New Issue
Block a user