Script Effect
Demonstrates how to listen to two specific signals of AGMakerManager in GDScript.
Key Points
- AGMakerManager has two specific signals:
on_savedandon_loaded. - When we call save and load actions in VS, these two signals are triggered, providing an integer parameter
slot_indexto indicate which file slot triggered the save or load. - Using these two signals, you can create custom save and load behaviors that are independent of the GameObject lifecycle.
- Attach the following script to any Node present in the scene tree. Execute “save game” and “load game” actions in any GameObject’s VS script to see related text output in the console.
- This method is particularly suitable for scenarios where various save data need to be customized. For example, selectively extracting certain data from a database, or when there is native Godot data outside the AGM system that needs to be saved and restored after AGM’s save and load are completed.
- For specific methods on how to serialize and deserialize (save data to and read from the hard drive), please refer directly to the Godot documentation link provided in the example code.
Core
extends Node
func _ready() -> void:
AGMakerManager.on_saved.connect(_on_agm_saved)
AGMakerManager.on_loaded.connect(_on_agm_loaded)
func _on_agm_saved(slot_index:int):
print("on_agm_saved: slot = ", slot_index)
# Do anything you want to do here.
# Example:
# https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html#saving-and-reading-data
pass
func _on_agm_loaded(slot_index:int):
print("on_agm_loaded: slot = ", slot_index)
# Do anything you want to do here.
pass