Script Effect
Demonstrates how to listen to two unique signals of AGMakerManager in GDScript.
Key Points
- AGMakerManager has two unique signals:
on_savedandon_loaded. - When we call save and load actions in VisualScript (VS), these two signals are triggered and provide an integer parameter
slot_indexto indicate which file slot triggered the save or load operation. - These two signals can be used to create custom save and load behaviors independent of the GameObject’s lifecycle.
- Attach the following script to any Node present in the scene tree. Then, execute the “Save Game” and “Load Game” actions in the VS script of any GameObject, and you will see the relevant text printed in the console.
- This method is especially suitable for scenarios requiring custom data saving. For example, selectively extracting certain data from a database, or saving and restoring native Godot data outside the AGM system after AGM’s save/load operations are completed.
- For specific methods on how to serialize and deserialize (storing data to disk and reading it out), please refer directly to the Godot documentation links 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