PluginContext¶
Type
PluginContext passes Studio's selection, snap steps, camera state, the seats of the edit session, and (inside Execute) Edit to Poll, Execute, and Modal. Studio builds a fresh context per call; do not store it across calls.
Selection¶
Selection is the array of entities selected in Studio at call time.
MoveIncrement¶
MoveIncrement is Studio's move snap step in units.
RotateIncrement¶
RotateIncrement is Studio's rotate snap step in degrees.
Camera¶
Camera: {Position: vector, Pivot: vector, Yaw: number, Pitch: number, Distance: number, Focused: boolean}
Camera is Studio's edit camera table: Position and Pivot in world units, Yaw and Pitch in degrees, Distance in units, and Focused (true when right-drag orbits Pivot).
Seats¶
Seats: {{Id: number, Name: string, Kind: "person" | "agent", Color: vector, You: boolean, Selection: {Entity}}}
Seats lists every live seat in the edit session, one table each: Id (0 to 15), Name, Kind ("person" or "agent"), Color (the color of the seat's outline and camera marker, as a vector of red, green, and blue, each from 0 to 1), You (true for the seat that runs the plugin), and Selection (the entities that seat has selected, at most the first 64). A plugin cannot change the list or move another seat's camera, and game scripts do not see seats.
Example
-- Plugin script (plugins/team/init.luau).
plugin:Operator({
Id = "team.select_shared",
Label = "Select What Others Selected",
Execute = function(ctx: PluginContext)
local list = {}
for _, seat in ctx.Seats do
if not seat.You then
for _, inst in seat.Selection do
table.insert(list, inst)
end
end
end
(ctx.Edit :: PluginEdit):Select(list)
return true
end,
})
Snap¶
Snap takes (value, increment, from, to) and clamps value between from and to, rounding to steps of increment from math.min(from, to) when increment > 0.
Example
-- Plugin script (plugins/build/init.luau).
plugin:Operator({
Id = "build.snap_height",
Label = "Snap Height",
Execute = function(ctx: PluginContext)
local edit = ctx.Edit :: PluginEdit
for _, part in ctx.Selection do
local pos = part.Position
if pos then
local y = ctx.Snap(pos.Y, ctx.MoveIncrement, 0, 100)
edit:Set(part, "Position", Vector3.new(pos.X, y, pos.Z))
end
end
return true
end,
})
Edit¶
Edit is the PluginEdit handle inside Execute, or nil in Poll and Modal. Changing the place directly outside ctx.Edit raises an error.