Skip to reading
Lua Scripting

Cross-language calls and includes

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

LESSON 16

Let a single implementation of a puzzle rule serve Lua, GDScript and an action list.

Lua caller · bridge_lua#

Code example
local Script = {}
Code example
function Script.run(context)
    local helper = IncludeScript("archive_words")
    helper:Set("last_room", "archive")
    local answer = await(AwaitCall(helper, "Call", "normalize",
                                   Array{"  EAST "}))
    return tostring(answer) .. "/" .. tostring(helper:Get("last_room"))
end
Code example
return Script

Expect east/archive. IncludeScript returns a call proxy. Set and Get use its shared included-variable

store. The proxy does not copy source or give you a reference to the other module's private locals.

Lua project records need no header files. A standalone Lua require uses the Lua package loader and

its search paths. Use project IDs and IncludeScript or CallScript for records packaged by PCA.

GDScript caller · complete native record#

Code example
func run() -> String:
    var value = await CallScript("archive_words", "normalize", [" WEST "])
    return str(value)

From Lua use await(CallScript(id, functionName, Array{arguments})). The shared router also

supports PCA Script and BASIC records. Use unique record IDs across languages. RunVisualScript

takes a scriptId for a saved graph. RunVisualGraph takes the graph data itself. Return plain

numbers, strings, booleans and simple lists or dictionaries for portable results.

Page 34 of 133Permalink
Go to page