Skip to reading
Buttons, Labels & Text Boxes

The complete Save Name script

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var entered: String = str(GetGUIElementProperty(
        "register_panel", "name_box", "text", ""
    )).strip_edges()
Code example
    if entered.is_empty():
        await SetVariable({
            "name": "feedback",
            "value": "Please enter a visitor name."
        })
        return false
Code example
    await SetVariable({
        "name": "visitor_name", "value": entered
    })
    await SetVariable({
        "name": "feedback",
        "value": "Name saved in the register."
    })
    return true

Read the parts that you may want to change#

Source table from The complete Save Name script, page 27
PartMeaning
register_panel / name_boxThe GUI and the specific input control.
textRead the current editable contents, not the original definition's value.
The final empty StringFallback if the field cannot be found.
strip_edges()Remove spaces at the beginning and end. It keeps the name's internal spaces and letter case.

This saves the name in a runtime variable. It does not rename the active Character definition. Use @PlayerName for the character and $$visitor_name for the separate entered name.

Page 27 of 46Permalink
Go to page