PropPlacer
constPropPlacer:object
Defined in: client/api.d.ts:2731
Placement mode: a translucent preview under the crosshair, tinted for whether the spot is accepted, put down with a click.
The loop is native and runs with the game’s own frame, so the preview tracks the camera exactly and no script runs per frame. While a session is up this client’s input belongs to it, the way one of the game’s own screens takes it – which is what stops a confirm click also swinging the player’s sword, and what stops the player walking away mid-placement.
One session at a time, and it belongs to the resource that started it: a resource that stops takes its session with it.
Nothing here is authority. The rules below colour a preview at one client. What actually gets built is the server’s decision, made again from the pose the client confirmed – two players aiming at the same patch of ground both see green.
Type Declaration
Section titled “Type Declaration”begin()
Section titled “begin()”begin(
options):boolean
Starts placement. The preview appears under the crosshair on the same frame.
Parameters
Section titled “Parameters”options
Section titled “options”model, models, offsets and rotations describe the preview exactly as PropGhost.create takes them.
validTint and invalidTint are the two colours the preview flips between, translucent green and translucent red by default. range is how far the aim ray reaches in metres (40 by default, up to 512) and fallbackDistance is where the preview sits when the ray reaches nothing. verticalOffset lifts or sinks it, yaw is a fixed turn added to whatever the aim settles on, and the mouse wheel moves that while a session is up.
alignToSurface stands the preview on the slope it is aimed at instead of upright; faceAwayFromPlayer turns it to face away from where you stand, which is what a wall or a tower wants and is on by default. keepOpen leaves the session running after a confirm so several can be placed in one go, and is on by default.
rules is what the preview is tinted by, and every one of them is off unless named. maxSlope is degrees the ground may lean; surfaces is which surface names are allowed; minDistance and maxDistance bound how far from the player it may stand; clearance is metres that must be free of other entities, narrowed to clearanceClasses when given; requireSurface refuses a spot the ray never reached, and is on by default.
alignToSurface?
Section titled “alignToSurface?”boolean
faceAwayFromPlayer?
Section titled “faceAwayFromPlayer?”boolean
fallbackDistance?
Section titled “fallbackDistance?”number
invalidTint?
Section titled “invalidTint?”keepOpen?
Section titled “keepOpen?”boolean
model?
Section titled “model?”string
models?
Section titled “models?”string[]
offsets?
Section titled “offsets?”Vector3[]
range?
Section titled “range?”number
rotations?
Section titled “rotations?”rules?
Section titled “rules?”{ clearance?: number; clearanceClasses?: string[]; maxDistance?: number; maxSlope?: number; minDistance?: number; requireSurface?: boolean; surfaces?: string[]; }
rules.clearance?
Section titled “rules.clearance?”number
rules.clearanceClasses?
Section titled “rules.clearanceClasses?”string[]
rules.maxDistance?
Section titled “rules.maxDistance?”number
rules.maxSlope?
Section titled “rules.maxSlope?”number
rules.minDistance?
Section titled “rules.minDistance?”number
rules.requireSurface?
Section titled “rules.requireSurface?”boolean
rules.surfaces?
Section titled “rules.surfaces?”string[]
scale?
Section titled “scale?”number
validTint?
Section titled “validTint?”verticalOffset?
Section titled “verticalOffset?”number
number
Returns
Section titled “Returns”boolean
True when the session started; false when one is already running, when this client has no world or camera, when another part of the mod holds the controls, and when the preview could not be built.
end():
void
Ends the session and gives the player their input back. end is raised. Doing nothing when no session is running is not an error.
Returns
Section titled “Returns”void
getPose()
Section titled “getPose()”getPose():
PlacementPose|null
Where the placement is aimed right now, without waiting for a move.
Returns
Section titled “Returns”PlacementPose | null
The pose, or null when no session is running and before the first aim settles.
isActive()
Section titled “isActive()”isActive():
boolean
Whether a placement session is running at this client right now.
Returns
Section titled “Returns”boolean
True while one is up.
on(
event,handler):Unsubscribe
Listens for one of the session’s events. Handlers belong to the resource that registered them and go when it stops.
Parameters
Section titled “Parameters”"rejected" | "move" | "confirm" | "cancel" | "end"
move fires when the aim has travelled far enough to be worth reporting, and whenever the spot flips between accepted and refused – it is throttled on purpose, because it is the one event that could otherwise fire every frame. confirm is a click the rules accepted, and is the one to send to the server. rejected is a click they refused, so the resource can say why; the session stays up. cancel is the player backing out. end is the session stopping, however it stopped, and is always the last one.
handler
Section titled “handler”PlacementHandler<PlacementPose>
Called with where the placement is aimed and whether that spot is accepted. The pose is null for cancel and end.
Returns
Section titled “Returns”A function that removes this subscription.
rotate()
Section titled “rotate()”rotate(
degrees):boolean
Turns the preview, the same way the mouse wheel does while a session is up.
Parameters
Section titled “Parameters”degrees
Section titled “degrees”number
How far to turn it, in degrees. Negative turns the other way.
Returns
Section titled “Returns”boolean
True while a session is running.
setVeto()
Section titled “setVeto()”setVeto(
vetoed):boolean
Refuses every spot until cleared, which is where a rule the engine cannot answer belongs – what the player can afford, what the server has already said no to. It latches, so it costs the placement loop nothing.
Parameters
Section titled “Parameters”vetoed
Section titled “vetoed”boolean
Whether to refuse the spot whatever the rules say.
Returns
Section titled “Returns”boolean
True while a session is running.