Skip to reading
GDScript Programming & Godot

51. Call PCA Script, Lua, BASIC and visual graphs

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
func run() -> Array:
    var pca_result: Variant = await CallScript("utility_pca", "add_points", [10, 5])
    var lua_result: Variant = await CallScript("math_lua", "add_points", [10, 5])
    var basic_result: Variant = await CallScript("math_basic", "AddPoints", [10, 5])
    return [pca_result, lua_result, basic_result]

CallScript routes the ID to the correct supported language. The argument array is positional. The optional context dictionary merges with the caller context. Returned plain arrays/dictionaries are the clearest interchange format.

Use the matching language syntax in the helper record. A PCA helper uses function/end; Lua returns a module table; BASIC uses FUNCTION/END FUNCTION. The same helper names from the PCA Script guide can be reused without changing their language.

For a saved visual script, call its record ID through the router/shared run-script action. RunVisualGraph instead accepts the graph data dictionary. It is not a shorthand for an ID lookup.

Native Godot Node/Resource objects are not a portable return contract for every language or save format. Pass IDs and ordinary data unless the receiving route explicitly supports the object type.

Page 60 of 378Permalink
Go to page