Engine Class
ChangeHistoryService
Summary
Methods
FinishRecording(identifier: string,operation: Enum.FinishRecordingOperation,finalOptions: Dictionary?):() |
IsRecordingInProgress(identifier: string?):boolean |
Redo():() |
ResetWaypoints():() |
SetEnabled(state: boolean):() |
SetWaypoint(name: string):() |
TryBeginRecording(name: string,displayName: string?):string? |
Undo():() |
Events
OnRecordingFinished(name: string,displayName: string?,identifier: string?,operation: Enum.FinishRecordingOperation,finalOptions: Dictionary?):RBXScriptSignal |
OnRecordingStarted(name: string,displayName: string?):RBXScriptSignal |
OnRedo(waypoint: string):RBXScriptSignal |
OnUndo(waypoint: string):RBXScriptSignal |
API Reference
Methods
FinishRecording
ChangeHistoryService:FinishRecording(
):()
Parameters
Returns
()
Code Samples
ChangeHistoryService:TryBeginRecording
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Example Plugin")
local button = toolbar:CreateButton("Neon it up", "", "")
button.Click:Connect(function()
local parts = {}
for _, part in pairs(Selection:Get()) do
if part:IsA("BasePart") then
parts[#parts + 1] = part
end
end
if #parts < 1 then
-- Nothing to do.
return
end
local recording = ChangeHistoryService:TryBeginRecording("Set selection to neon")
if not recording then
-- Handle error here. This indidcates that your plugin began a previous
-- recording and never completed it. You may only have one recording
-- per plugin active at a time.
return
end
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end)IsRecordingInProgress
Redo
ChangeHistoryService:Redo():()
Returns
()
ResetWaypoints
ChangeHistoryService:ResetWaypoints():()
Returns
()
SetWaypoint
Parameters
Returns
()
Code Samples
ChangeHistoryService:SetWaypoint
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Example Plugin")
local button = toolbar:CreateButton("Neon it up", "", "")
button.Click:Connect(function()
local parts = {}
for _, part in pairs(Selection:Get()) do
if part:IsA("BasePart") then
parts[#parts + 1] = part
end
end
if #parts > 0 then
-- Calling SetWaypoint before the work will not cause any issues, however
-- it is redundant, only the call AFTER the work is needed.
--ChangeHistoryService:SetWaypoint("Setting selection to neon")
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
-- Call SetWaypoint AFTER completing the work
ChangeHistoryService:SetWaypoint("Set selection to neon")
else
-- Nothing to do. You do not need to call SetWaypoint in the case where
-- the action did not end up making any changes to the experience.
end
end)TryBeginRecording
Returns
Code Samples
ChangeHistoryService:TryBeginRecording
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Example Plugin")
local button = toolbar:CreateButton("Neon it up", "", "")
button.Click:Connect(function()
local parts = {}
for _, part in pairs(Selection:Get()) do
if part:IsA("BasePart") then
parts[#parts + 1] = part
end
end
if #parts < 1 then
-- Nothing to do.
return
end
local recording = ChangeHistoryService:TryBeginRecording("Set selection to neon")
if not recording then
-- Handle error here. This indidcates that your plugin began a previous
-- recording and never completed it. You may only have one recording
-- per plugin active at a time.
return
end
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end)Undo
ChangeHistoryService:Undo():()
Returns
()
Events
OnRecordingFinished
ChangeHistoryService.OnRecordingFinished(
name:string, displayName:string?, identifier:string?, operation:Enum.FinishRecordingOperation, finalOptions:Dictionary?
Parameters
OnRecordingStarted