Skip to reading
GDScript Programming & Godot

Registry and script-call methods

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
Source table from Registry and script-call methods, page 225
MethodContract
registry.Get(id) / get_record(id)Obtain a record proxy. Check Has/Exists when absence is possible.
registry.Has(id)Check that the runtime record exists.
registry.IDs()Array[String] of IDs in that registry.
Global.Get(script_id) / Global.script_idObtain a script-call proxy.
Global.IDs()Known script IDs.
call_proxy.Call(function, arguments, context)Await a named routed function.
call_proxy.Run(context)Await the record’s default run route.
call_proxy.Get(name, fallback)Read included-variable data for that script ID.
call_proxy.Set(name, value)Write included-variable data; not an ordinary script member.
call_proxy.Emit(event_name, context)Invoke that script’s event route directly with inherited/overridden context.
Code example
var library: Variant = IncludeScript("utility_gd")
var result: Variant = await library.Call("add_points", [10, 5])
library.Set("last_total", result)

A convenient member access such as Global.utility_gd is a call proxy, not the kept-alive Node itself. Avoid reaching into another script’s private native instance as an undocumented state-sharing mechanism.

Page 225 of 378Permalink
Go to page