carry.module
This package holds more than this page lists. See all of its files in its world.
README.md
carry
Holding and carrying world props. An avatar picks up a prop marked Holdable into a grip point (a hand, the chest for a large object, the mouth or a paw of a non-humanoid body), carries it, puts it down, places it, throws it with the grip's velocity, or passes it to another avatar. The Carrier component wires these to the player's controls (a tap hands the prop to the player in front); this module is the same capability for any script.
local carry = require("@builtin::modules.carry")
local me = layers.active.players.localPlayer.avatar
carry.pickUp(me, carry.nearest(me, { reach = 2 }))
carry.throw(me, { 0, 3, -7 })
API
| Call | Returns |
|---|---|
carry.pickUp(holder, prop) | (ok, why). Takes ownership of the prop first (asking the peer that owns it, and waiting up to carry.handOverSeconds), then holds it in the grip its Holdable names. A prop another avatar holds is refused. |
carry.drop(holder) | The prop let go, falling from the hand with the grip's velocity, or nil. |
carry.place(holder, position, rotation?) | The prop put down there at rest, or nil. |
carry.throw(holder, velocity) | The prop thrown with the grip's velocity plus velocity, or nil. |
carry.give(holder, receiver) | (ok, why). Into the receiver's grip at once when this peer owns it; otherwise offered to the receiver's peer. A receiver whose hands are full is refused, and the holder keeps the prop. |
carry.nearestReceiver(holder, { reach?, facing? }) | The nearest other avatar carrying a Carrier that accepts gifts and holds nothing, in front of the holder within reach (2.5 m): the one a tap of the Carrier's control hands the prop to. Nil when none stands there. |
carry.heldBy(holder) | The prop the holder holds, or nil. |
carry.holderOf(prop) | The avatar holding the prop, or nil. |
carry.nearest(holder, { reach?, facing? }) | The nearest loose holdable prop in front of the holder within reach (1.6 m), or nil. |
carry.facing(holder) | x, z: the way the holder visibly faces along the ground (the rotation anchor Locomotion turns a player's body by, else its own forward). "In front" for nearest and nearestReceiver. |
carry.gripOf(holder, point) | The entity carrying a grip point: a humanoid's attachment-point bone, or the entity of that name under any other body. |
carry.seat(holder, prop, point, position?, rotation?) | (ok, why): moves the prop onto the grip, leaving its physics and its holder as they stand. |
carry.holdables() | Every entity carrying Holdable. |
carry.acceptsGifts(receiver) | Whether an avatar takes what it is given (its Carrier's acceptGifts). |
Across peers
The peer that holds a prop owns it, and every peer reads the holder from the prop's Holdable.holder. A pick-up of a prop another peer owns sends that peer a request; it hands the prop over (releasing it) when nobody holds it, and the asker claims it once it reads that release. A gift to another peer's avatar is offered to that peer, whose avatar asks for it, and the giver lets it go in place for the receiver's grip. Calls that wait for another peer yield, so make them from code that can yield.