Skip to reading
GDScript Programming & Godot

CallScript()

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
On this page
Code example
CallScript(script_id: String, function_name: String = "run", arguments: Array = [],
execution_context: Dictionary = {}) -> Variant

Call a function through the shared language router, merging additional context with the current caller.

Returns: The called function’s return value.

Code example
await CallScript("utility_gd", "add_points", [10, 5])

Argument array order must match the function. Use unique script IDs across languages.

IncludeScript()#

Code example
IncludeScript(script_id: String) -> RefCounted

Obtain a script-call proxy through Global.Get.

Returns: RefCounted call proxy, or null if the registry is unavailable.

Code example
IncludeScript("utility_gd")

This does not paste source or return the other script’s actual Node. Use the proxy’s Call/Run/Get/Set/Emit methods.

GetIncludedVariable()#

Code example
GetIncludedVariable(script_id: String, variable_name: String, fallback: Variant = null) ->
Variant

Read router-owned per-script shared data.

Returns: Stored value or fallback.

Code example
GetIncludedVariable("utility_gd", "last_total", 0)

This store is separate from a script’s member variables and ordinary save-game variables.

Page 67 of 378Permalink
Go to page