Personal notebook controller - part 2 of 3
func render() -> void:
if not is_instance_valid(Runtime):
return
var values: Dictionary = Runtime.get("variables")
var actor: String = ActivePlayer()
var selected: String = str(values.get("journal_choice", ""))
previous = actor + "|" + selected
var body: String = "Choose an entry to read it."
var entries: Array = values.get("journal_" + actor, [])
for entry: Dictionary in entries:
if str(entry.get("id", "")) == selected:
body = str(entry.get("text", "")) + "\n\n" + str(entry.get("body", ""))
break
var manager: Node = Runtime.get("authored_gui_manager")
if not is_instance_valid(manager):
return
var nodes: Dictionary = manager.get("element_nodes")
for owner: String in ["tester", "assistant"]:
var reader: TextEdit = nodes.get(owner + "_journal_body") as TextEdit
if not is_instance_valid(reader):
continue
reader.editable = false
if owner == actor:
reader.text = bodyThe reader displays the selected entry’s title and body. Its editing is disabled, while normal scrolling remains available. A character with no selected entry gets a plain instruction instead of another character’s previous text.
The owner list contains tester and assistant. Extend it, and create the matching reader IDs, when adding more playable characters.
