Skip to reading
Visual Scripting in Depth

46. Call Lua and BASIC functions too

Edition 0.86.4.3

0.86.4.3 edition with revised lessons, updated cross-references and new cinematic/camera-safety supplements. Earlier examples, screenshots and registry figures retain their stated edition context.

Download PDFView PDF page

The same definition and caller workflow is available for Lua and BASIC. These two examples return the same amount/label dictionary.

Code example
local Script = {}
function Script.describe(amount, label)
    return {amount = amount, label = label}
end
return Script
Code example
FUNCTION describe(amount, label)
    RETURN {"amount": amount, "label": label}
END FUNCTION

1. Create a Lua record lua_tools or BASIC record basic_tools and enter the matching source.

2. Expose describe with amount:int and label:string in that order.

3. Accept the definitions, apply the script editor changes and save.

4. Add or select Call Script Function in the visual caller.

5. Choose the intended language’s helper and verify the result.

The Lua example returns its Script table. The BASIC example uses FUNCTION and END FUNCTION. Neither example needs a default run function because it is called by the named function.

Language syntax still matters inside each helper. Exposure makes the call form consistent; it does not make Lua table syntax interchangeable with JSON or GDScript.

Page 50 of 93Permalink
Go to page