Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var savefile_path = "user://player.save"
- func saveGame():
- var save_data = {
- "Money":
- Player.Money,
- "Level":
- Player.Level,
- "Exp":
- Player.XP,
- "Nexp":
- Player.Nexp
- }
- var file = FileAccess.open(savefile_path, FileAccess.WRITE)
- file.store_var(Player.Money)
- file.store_var(Player.Level)
- file.store_var(Player.XP)
- file.store_var(Player.Nexp)
- file.close()
- func loadGame():
- if(FileAccess.file_exists(savefile_path)):
- var file = FileAccess.open(savefile_path, FileAccess.READ)
- Player.Money = file.get_var(Player.Money)
- Player.Level = file.get_var(Player.Levek)
- Player.XP = file.get_var(Player.XP)
- Player.Nexp = file.get_var(Player.Nexp)
- file.close()
- else:
- print("No data has been saved...")
- Player.Money = 0
- Player.Level = 1
- Player.XP = 0
- Player.Nexp = 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement