Skip to reading
The Variable Designer

The same change in Lua and BASIC

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

Lua#

Create a Lua script record, validate and apply it, then call it from an action list. This version uses the shared ChangeVariable action helper.

Code example
local Script = {}
Code example
function Script.run(context)
    await(ChangeVariable({
        name = "score", operation = "add", value = 5
    }))
    return true
end
Code example
return Script

BASIC#

Create a BASIC script record with this source. The wrapper identifies PCA 3D BASIC 1.0, and AWAIT calls the same variable-changing helper.

Code example
OPTION PCA3D BASIC 1.0
FUNCTION Run(context AS Dictionary)
    AWAIT ChangeVariable({"name": "score", "operation": "add", "value": 5})
    RETURN TRUE
END FUNCTION
Source table from The same change in Lua and BASIC, page 30
Test runScore beforeScore after
Lua helper2025
BASIC helper2530
PCA Script global3035

These changes all reached the same shared score in the runtime test. Lua locals and ordinary BASIC local/private values remain script data; they do not become designer records just because they use the same name.

BASIC also provides GLOBAL / SHARED declarations for runtime state. For the small example here, using ChangeVariable keeps the operation explicit and avoids confusing local declarations with the global designer value.

Page 30 of 37Permalink
Go to page