33. Work with GDScript, Lua and BASIC
PCA Script, native GDScript, Lua, BASIC and visual graphs share a script router and gameplay runtime. They do not share one syntax. Use call_script(id, function, arguments, context) at the boundary and pass ordinary data.
A native GDScript helper can supply an operation PCA does not have. Create a GDScript record
math_native using the native Script workspace. A record without an explicit extends line receives the engine’s script base.
function run()
return call_script("math_native", "square_root", [81])
endfunc square_root(value: float) -> float:
return sqrt(value)The small block above is GDScript, not PCA Script. A call to square_root with 81 returns 9. A native helper can use supported Godot APIs; it must still be written and tested for the platforms you intend to export.
For a Lua record math_lua, use this module. Lua’s ordinary numeric array syntax starts at 1 inside Lua; data crossing the bridge is normalized to PCA/Godot arrays, which are zero-based in PCA.
local Script = {}
function Script.add_points(base, bonus)
return base + bonus
end
return Scriptfunction run()
return call_script("math_lua", "add_points", [10, 5])
endLua action wrappers that return a signal need Lua’s await(...). PCA calls handle their own suspension; do not paste that Lua await syntax into PCA source.
