Skip to reading
Lua Scripting

Write a camera rule in Lua

Edition 0.86.4.9

0.86.4.9 tutorial edition. Earlier lessons, screenshots and aggregate registry figures retain their stated edition context; the linked revised lessons cover the newer camera and workshop workflows.

Download PDFView illustrations

TUTORIAL EDITION / 0.86.4.9

CHANGE A RUNNING GAME

Put the function on your Lua module table and return that table at the end. The await call lets PCA finish the checked write before the reply is returned.

The camera property selected in the reference

Read/write access and immediate updates

01. Call the function in the workshop

Open Camera-Safety-Workshop.pca3d. Create a Lua script record, enter the function below and apply. Call checked (Checked in BASIC) while the workshop room is running.

Code example
local Script = {}
function Script.checked()
    local args = {cameraId="protected",
        property="cameraSafety.maxAngle", value=35}
    return await(ActionResult("ChangeCameraProperty", args))
end
return Script

02. Read the reply

The registered action is ChangeCameraProperty. For this call the reply includes ok = true, result.status = applied and result.effective = 35. An unsuccessful call should be handled before you read the result.

Check your result The protected camera starts with shorten recovery. Try shoulderSearch on a moving shot to see the angle limit affect framing. Reading occlusionState on the active camera gives you its live diagnostics.

Lua Programming Guide

Page 138 of 139Permalink
Go to page