【Deep Dive into AGMaker】Script Snippets - Custom Save and Load Behavior

Script Effect

Demonstrates how to listen to two unique signals of AGMakerManager in GDScript.

Key Points

  1. AGMakerManager has two unique signals: on_saved and on_loaded.
  2. When we call save and load actions in VisualScript (VS), these two signals are triggered and provide an integer parameter slot_index to indicate which file slot triggered the save or load operation.
  3. These two signals can be used to create custom save and load behaviors independent of the GameObject’s lifecycle.
  4. 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.
  5. 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.
  6. 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
1 Like