Fungi
Click to target actors
Bind a game command to clicking an eligible actor.
actorTarget(component) connects a command’s input schema, eligible subjects
and click binding. The client offers clicks only for visible actors that still
have that component; the command handler remains responsible for game rules.
For example, add a pet command to the Acorn starter. Visual is already on
the starter’s trees and cats:
const target = actorTarget(Visual);const pet = command({ title: "Pet", category: "Acorn", description: "Choose an actor to pet.", input: target.input, reads: [Visual], writes: [], subjects: target.subjects, localPresentation: { bindings: [{ id: "pet", label: "Pet", ...target.binding }], }, run(_context, { entity }) { return { actions: [], writes: [] }; },});Import actorTarget and Visual from vishnu, add pet beside plant in
commands, and keep the handler’s reads and writes aligned with its actual game
effect. The example handler deliberately has no effect.
vishnu check && vishnu test && vishnu build