Personal notebook controller - part 1 of 3
Record ID: journal_tools. Global Script: on. Subscribe to OnPlayerChanged and OnSaveLoaded. All three parts belong to the same record.
extends "res://scripts/runtime/script_base.gd"var previous: String = ""func on_global_ready(_context: Dictionary = {}) -> void:
set_process(true)
render()func on_player_changed(_context: Dictionary = {}) -> void:
await SetVariable({"name":"journal_choice", "value":""})
render()func on_save_loaded(_context: Dictionary = {}) -> void:
render()func _process(_delta: float) -> void:
var values: Dictionary = Runtime.get("variables")
var current: String = ActivePlayer() + "|" + str(values.get("journal_choice", ""))
if current != previous:
render()The player-change hook clears the old selected entry ID. The save-loaded hook redraws the reader from restored data. The small frame check notices the player selecting another title.
The event names in the subscription controls correspond to the on_player_changed and on_save_loaded functions. Defining those functions without the subscriptions is incomplete setup.
