Log inGet started
World

Save Point

Branchmain
Branchesmain
Commit8937fc8d08

README.md

focus

One interaction target at a time, chosen by aim. Every interactable (door, light switch, seat, TV, controller, the Game Boy) offers itself each frame while the player is in its range; the focus picker takes the one the middle of the screen looks at (turning counts fully, the follow camera's pitch only partly, since it cannot look straight down at a table), and only when nothing is under the reticle the nearest one, favouring what is in front and bigger things. Only the winner shows a prompt and only the winner acts on Interact.

Input contexts, innermost first (Focus.context()): shelf (cartridge shelf open: its own map stations.shelf stands the player's and the held console's controls down; Back = Backspace / pad B closes it), pad (a controller in hand: stations.gamepad stands the player's and hangout maps down; its own pad_watch frames the TV), handheld (the Game Boy in hand: stations.handheld), holding, seated, free. With something in hand only an offer made with a press callback is considered (a seat: sit with the item kept in hand; a held controller's "Cartridges"): it shows the prompt and the stations.holdInteract map (E / pad right-stick click / touch "Use", live only then) calls press. Seated, look (mouse / right stick) turns the seated view (stations.seatView), so the reticle picks among what lies on the table. With a Game Boy in hand and standing, its close-up looks back at the player, so a press offer (a seat) is found from the body instead: within reach of the chest, nearest first — walk up to a seat and press Interact to sit with the Game Boy kept in hand.

The player's Carrier picks nothing up by itself (stations.hands binds its control to no device): each holdable's own component offers itself here and picks itself up when it is the target.

local Focus = require("stations.focus")
-- update(): offer while in range (player-facing verb and object, aim radius in metres), withdraw otherwise
Focus.offer(public.entityId, targetEntity, "Open", "Door", 0.5)
Focus.withdraw(public.entityId)
-- in the Interact handler:
if not Focus.isTarget(public.entityId) then return end