Skip to reading
Visual Scripting in Depth

35. Use a script-owned shared variable

Edition 0.86.4.3

0.86.4.3 edition with revised lessons, updated cross-references and new cinematic/camera-safety supplements. Earlier examples, screenshots and registry figures retain their stated edition context.

Download PDFView PDF page

Get Included Variable and Set Included Variable address a separate shared scope by script ID and variable name. They are useful when an included-script workflow needs state under that script’s identity.

Source table from 35. Use a script-owned shared variable, page 39
NodeExample fields
Set Included VariableScript gd_tools; Shared Variable shared_counter; Value 9.
Get Included VariableScript gd_tools; Shared Variable shared_counter; Store in Variable result_value.
Return{"$var":"result_value"} reads the copied result.

1. Choose an existing project script in Script.

2. Set the same Shared Variable name on the setter and getter.

3. Run the setter, then the getter.

4. Inspect the destination runtime variable.

5. Use a project variable instead when this is ordinary puzzle state that should be obvious in Variable Designer.

This scope is not an automatic window into every native GDScript member or Lua table field. It is the engine’s included-variable storage. The script ID has to be known; a missing source or never-written name can yield no value.

Keep the scope clear in your notes. Project variable shared_counter and an included variable called shared_counter are different locations, even though the names match.

Page 39 of 93Permalink
Go to page