Advertisement
Aighton

Godot Config Save File Location 3D

May 3rd, 2020
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #the SaveSystem Code
  2. extends Node
  3.  
  4. var save_path = "res://save-file.cfg"
  5. var config = ConfigFile.new()
  6. var load_response = config.load(save_path)
  7. var locationCharacter
  8.  
  9. func saveValue(section, key):
  10. config.set_value("Values", "ValueSeven", locationCharacter)
  11. config.save(save_path)
  12.  
  13. func loadValue(section, key):
  14. locationCharacter = config.get_value("Values", "ValueSeven", locationCharacter)
  15.  
  16.  
  17. #the World Code
  18. extends Spatial
  19.  
  20. func _ready():
  21. $"/root/SAVEGAME".loadValue("Values", "ValueSeven")
  22. $Player.translation = $"/root/SAVEGAME".locationCharacter
  23.  
  24. $Control/Timer.start()
  25.  
  26. func _process(delta):
  27. $Control/Loc.text = str($"/root/SAVEGAME".locationCharacter)
  28.  
  29. if Input.is_action_just_pressed("ui_cancel"):
  30. SAVEGAME.locationCharacter = $Player.transform.origin
  31. $"/root/SAVEGAME".saveValue("Values", "ValueSeven")
  32.  
  33. get_tree().quit()
  34.  
  35. func _on_Timer_timeout():
  36. SAVEGAME.locationCharacter = $Player.transform.origin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement