Extension point A
Actor adapter
Answers two questions about one class of thing: what can be observed about it, and what can be asked of it. observe normalises state inward; actions declares the surface outward; apply actuates after the decision has already been approved.
return Runtime.defineAdapter({
id = "machine/gantry",
-- Normalise the model into the observation the kernel reasons over.
observe = function(model)
return {
boom_angle = model.Boom:GetAttribute("Angle"),
hoist_height = model.Hoist.Position.Y,
payload = model:GetAttribute("PayloadId"),
envelope = { radius = 42, height = 28 },
faults = model:GetAttribute("Faults") or {},
}
end,
-- Everything this embodiment can be asked to attempt.
actions = {
slew = { params = { angle = "number" }, cost = { power = 2 } },
hoist = { params = { height = "number" }, cost = { power = 3 } },
grip = { params = { target = "Instance" } },
release = {},
},
-- Actuation only. Validation and resource settlement already happened.
apply = function(model, action, params)
if action == "slew" then
model.Boom:SetAttribute("TargetAngle", params.angle)
end
end,
})