![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | magagovnarita |
First scene script except variables and other unnecessary lines-
func _on_save_pressed():
get_node("/root/savesystem").szhr = zhr
get_node("/root/savesystem").saveValue("Values", "ValueOne")
func _on_Load_pressed():
get_node("/root/savesystem").loadValue("Values", "ValueOne")
zhr = get_node("/root/savesystem").szhr
Second scene script-
extends Node2D
var sves = 0
var szhr = 0
var save_path = "res://save-file.cfg"
var config = ConfigFile.new()
var load_response = config.load(save_path)
func _ready():
pass
func saveValue(section, key):
config.set_value(section, key, szhr)
config.save(save_path)
func loadValue(section, key):
szhr = config.get_value(section, key, szhr)
I already tried to make two “func saveValue(section, key):” methods in 1 scene, and I read documentation about basic savings but it’s not for my way.
I really need to make 10 scenes for 10 variables to save? Or how I can save more than 1 variables for 1 method. #bad english