![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Strussle |
The subsequent script is my SaveSystem, and it’s an AutoLoad scene that does what the name implies. When it’s booted up, it’s supposed to read the values from a cfg and set the variables it’s in charge of based on those values.
It does this correctly for Saving/Loading the last room the player was in, but it won’t read/load the values for the volume settings.
This line:
print("Last Room:", get_node("/root/SaveSystem").Last_Room, " Last Volume:", get_node("/root/SaveSystem").Old_Volume, " Last Music:", get_node("/root/SaveSystem").Old_Music)
-runs when the title screen launches, and it prints:
-so the Room save/load functionality is confirmed, but that same code doesn’t seem to be reading the values for Volume and Music correctly. The options menu is set to write those values into the file when you hit [Return] at the bottom of the menu, and it does; I can confirm it, but when the game starts up and SaveSystem runs it apparently doesn’t find anything there.
The Code in SaveSystem:
var Last_Room
var Old_Volume
var Old_Music
var save_path = "res://save-file.cfg"
var config = ConfigFile.new()
var load_response = config.load(save_path)
func _ready():
#LOAD THE LAST CHECKPOINT FROM SAVE FILE
Last_Room = get_node("/root/SaveSystem").Load_Room("Rooms", "LastRoom")
Old_Volume = get_node("/root/SaveSystem").Load_Volume("Sound A", "Old_Volume")
Old_Music = get_node("/root/SaveSystem").Load_Music("Sound B", "Old_Music")
#FUNCTION FOR SAVING THE LAST ROOM THE PLAYER WAS AT
func Save_Room(section, key):
config.set_value(section, key, Last_Room)
config.save(save_path)
func Load_Room(section, key):
Last_Room = config.get_value(section, key, Last_Room)
#FUNCTIONS FOR SAVING THE MASTER VOLUME SETTING
func Save_Volume(section, key):
config.set_value(section, key, Old_Volume)
config.save(save_path)
func Load_Volume(section, key):
Old_Volume = config.get_value(section, key, Old_Volume)
#FUNCTINOS FOR SAVING THE MUSIC VOLUME SETTING
func Save_Music(section, key):
config.set_value(section, key, Old_Music)
config.save(save_path)
func Load_Music(section, key):
Old_Music = config.get_value(section, key, Old_Music)