Skip to reading
Lua Scripting

Live records and the calling object

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

LESSON 14

Look up a character by ID and change only the record that the interaction concerns.

Code example
local Script = {}
Code example
function Script.run(context)
    local id = tostring(ActivePlayer())
    if not Character:Has(id) then return "No active character" end
    local actor = Character:Get(id)
    local label = actor:Get("name", id)
    Log("Active character: " .. tostring(label))
    return tostring(label)
end
Code example
return Script

Character is a registry. Character:Get(id) returns a record proxy and actor:Get(path, fallback) reads

a field. Character.ada is a shortcut for a fixed ID. Bracketed or method-based lookup accommodates

IDs that contain a dash. player identifies the active character. this is the caller proxy when the

interaction supplies an owner. A manual run may have no meaningful owner.

Fragments for an authored actor and room#

Code example
Character.elias:Set("name", "Master Clockmaker")
await(AwaitCall(Character.elias, "Say", "Count the chimes."))
await(ActivateCamera({ cameraId = "wide", duration = 0.5 }))
await(ChangeScene({ sceneId = "archive", spawnId = "entrance" }))

Create the referenced records first. Use colon syntax for a synchronous Godot object method. Use

AwaitCall for a yielding proxy method. The free-standing action wrappers take a Lua table. The

registry field list at the back describes which changes can update a live instance and which affect

its definition.

Page 32 of 133Permalink
Go to page