Skip to reading
Lua Scripting

Check a property write in Lua

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

0.86.4.0 / LUA

RUNTIME WALKTHROUGH

A PCA Lua module returns a table of functions. Wrap ActionResult in await so the reply is ready before you read it. This example returns the status on success or the error code on failure.

Code example
local Script = {}
Code example
function Script.checked()
Code example
    local args = {entityId="lamp", property="light.intensity", value=3.75}
Code example
    local r = await(ActionResult("ChangeObjectProperty", args))
Code example
    if not r.ok then return r.error end
Code example
    return r.result.status
Code example
end
Code example
return Script

1

Point the function at a real lamp#

In the room you will run, identify a placed 3D light. Use its entity ID in place of lamp. Start its intensity below 3.75. In the script designer for this language, add the function to the selected script, apply, and call it from an existing script event or exposed-function action. For Lua, keep one returned module table.

2

Read both outcomes#

Call once and look for applied. Call again without touching the lamp and look for unchanged. The Lua function returns that text directly. The other three return the reply: first inspect ok, then result.status on success or error and message on failure.

3

Find another call in the current catalog#

The following pages list every built-in action whose contexts include script. Copy the action ID and supply the named dictionary fields. For the three new setters, look up Change2DLayerProperty, ChangeCameraProperty and ChangeRoomProperty under C.

Two different kinds of reference

The earlier language chapters explain syntax, direct helpers and legacy wrappers. The regenerated pages below are the 0.86.4.0 lookup for checked action IDs and registered property paths. The reference window also shows choices, defaults, value limits and project functions.

PCA 3D / Lua

Page 94 of 133Permalink
Go to page