PluginEdit¶
Type
PluginEdit modifies the edit place inside an operator's Execute via ctx.Edit. World edits form one undo step and roll back if Execute returns false or errors; Select and SetCamera apply after Execute succeeds, outside the undo step.
Create¶
Create takes (class, props, parent), adds a new entity of class under parent (or the place root when nil), and returns it. In props, Frame copies the world pose of an entity.
Example
Copy¶
Copy duplicates inst under the same parent without children, scripts, decals, attachments, or welds, and returns the copy.
Example
-- Plugin script (plugins/build/init.luau).
plugin:Operator({
Id = "build.stack",
Label = "Stack Copy",
Execute = function(ctx: PluginContext)
local edit = ctx.Edit :: PluginEdit
local part = ctx.Selection[1]
if part then
local pos, size = part.Position, part.Size
if pos and size then
edit:Copy(part, { Position = pos + Vector3.new(0, size.Y, 0) })
end
end
return true
end,
})
Set¶
Set assigns inst[name] = value, moving descendants and welded parts on pose changes the same way Studio does.
Example
Reshape¶
Reshape sets part's size and world center while keeping children and welded parts at their world poses.
Example
-- Plugin script (plugins/build/init.luau).
plugin:Operator({
Id = "build.slab",
Label = "Make Slab",
Execute = function(ctx: PluginContext)
local edit = ctx.Edit :: PluginEdit
for _, part in ctx.Selection do
local size, pos = part.Size, part.Position
if size and pos then
edit:Reshape(part, Vector3.new(size.X, 1, size.Z), pos)
end
end
return true
end,
})
AddAccessory¶
AddAccessory takes (character, assetId, sha256?), loads the remote accessory scene named by assetId (verifying sha256 when given), and attaches it to the matching socket on character. It returns the accessory root, or nil and an error string when the asset cannot be loaded or attached.
Example
-- Plugin script (plugins/luduvo_tools/init.luau).
plugin:Operator({
Id = "luduvo.wear_hat",
Label = "Wear Hat",
Params = {
{ Name = "Character", Type = "instance", Hidden = true, From = "Selection" },
{ Name = "Asset", Type = "string", Label = "Accessory asset ID" },
},
Execute = function(ctx: PluginContext, params)
local edit = ctx.Edit :: PluginEdit
local character = params.Character :: Entity
local worn, err = edit:AddAccessory(character, params.Asset :: string)
if not worn then
return false, err
end
return true
end,
})
SetParent¶
SetParent moves inst under parent (or the place root when nil) while preserving its world transform.
Example
-- Plugin script (plugins/build/init.luau).
plugin:Operator({
Id = "build.group",
Label = "Group Selection",
Execute = function(ctx: PluginContext)
local edit = ctx.Edit :: PluginEdit
local folder = edit:Create("Folder", { Name = "Group" })
for _, inst in ctx.Selection do
edit:SetParent(inst, folder)
end
return true
end,
})
Destroy¶
Destroy removes inst and its descendants from the place.
Example
Select¶
Select sets Studio's selection (up to 4,096 entities) when Execute succeeds.
Example
SetCamera¶
SetCamera takes (position, yaw, pitch, distance) (with yaw and pitch in degrees) and moves Studio's edit camera when Execute succeeds. Passing distance focuses an orbit pivot that many units ahead of position.