Skip to content

Commit

Permalink
https://devforum.roblox.com/t/important-script-source-update-and-new-…
Browse files Browse the repository at this point in the history
…scripteditorservice-apis/2628171
  • Loading branch information
hoontee committed Oct 3, 2023
1 parent 26675f9 commit f713bdb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Binary file modified Lync/Plugin.rbxm
Binary file not shown.
26 changes: 21 additions & 5 deletions Lync/RobloxPluginSource/Plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ local CollectionService = game:GetService("CollectionService")
local CoreGui = game:GetService("CoreGui")
local HttpService = game:GetService("HttpService")
local RunService = game:GetService("RunService")
local ScriptEditorService = game:GetService("ScriptEditorService")
local Selection = game:GetService("Selection")
local StudioService = game:GetService("StudioService")
local TweenService = game:GetService("TweenService")
Expand Down Expand Up @@ -554,7 +555,13 @@ local function buildPath(path: string)
end)
activeSourceRequests -= 1
if success then
target.Source = result
if isBuildScript then
target.Source = result
else
ScriptEditorService:UpdateSourceAsync(target, function(_oldContent: string)
return result
end)
end
else
terminate(`The server did not return a source for '{data.Path}'`)
end
Expand Down Expand Up @@ -584,7 +591,13 @@ local function buildPath(path: string)
end)
activeSourceRequests -= 1
if success then
target.Source = result
if isBuildScript then
target.Source = result
else
ScriptEditorService:UpdateSourceAsync(target, function(_oldContent: string)
return result
end)
end
else
terminate(`The server did not return a source for '{data.Path}'`)
end
Expand Down Expand Up @@ -862,7 +875,7 @@ if not IS_PLAYTEST_SERVER then
for _, data in map do
if data.Instance == StudioService.ActiveScript then
local success, result = pcall(function()
HttpService:PostAsync("http://localhost:" .. getPort(), StudioService.ActiveScript.Source, Enum.HttpContentType.TextPlain, false, {Key = serverKey, Type = "ReverseSync", Path = data.Path})
HttpService:PostAsync("http://localhost:" .. getPort(), ScriptEditorService:GetEditorSource(StudioService.ActiveScript :: LuaSourceContainer), Enum.HttpContentType.TextPlain, false, {Key = serverKey, Type = "ReverseSync", Path = data.Path})
end)
if success then
print("[Lync] - Saved script:", data.Path)
Expand Down Expand Up @@ -905,14 +918,17 @@ if not IS_PLAYTEST_SERVER then
revertScript.MouseButton1Down:Connect(function()
if revertScript.Active and not revertScriptHeldTween then
local tween = TweenService:Create(revertScript.TextLabel.UIGradient, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Offset = Vector2.new(0.51, 0)})
revertScriptHeldTween =tween
revertScriptHeldTween = tween
tween:Play()
tween.Completed:Connect(function(playbackState: Enum.PlaybackState)
if playbackState == Enum.PlaybackState.Completed then
for _, data in map do
if data.Instance == StudioService.ActiveScript then
local success, result = pcall(function()
data.Instance.Source = HttpService:GetAsync("http://localhost:" .. getPort(), false, {Key = serverKey, Type = "Source", Path = data.Path})
local source = HttpService:GetAsync("http://localhost:" .. getPort(), false, {Key = serverKey, Type = "Source", Path = data.Path})
ScriptEditorService:UpdateSourceAsync(data.Instance, function(_oldContent: string)
return source
end)
end)
if success then
print("[Lync] - Reverted script:", data.Path)
Expand Down

0 comments on commit f713bdb

Please sign in to comment.