Skip to content

Commit

Permalink
Wait for game.Name to change before running rbx-reflector plugin (roj…
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethloeffler authored Sep 23, 2024
1 parent 757c137 commit d139189
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion rbx_reflector/plugin.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
if game.Name ~= "defaults-place.rbxlx" then
local function isDefaultsPlace()
-- After https://devforum.roblox.com/t/place-open-improvements-test/3086811, game.Name
-- is no longer immediately equal to its value defined in a place file after opening a
-- place file. Rather, game.Name is set the value defined in a place sometime after
-- the place is opened. We need to wait for game.Name to change before validating that
-- the place file in which this plugin is running is correct.

-- Since if or when game.Name changes seems to be an implementation detail, we
-- shouldn't assume game.Name will ever change. So, we'll wait for game.Name to
-- change, or else wait out a two second timeout, whichever comes first.
local didGameNameChange = false
local timeElapsed = 0

game:GetPropertyChangedSignal("Name"):Connect(function()
didGameNameChange = true
end)

while not didGameNameChange and timeElapsed <= 2 do
timeElapsed += task.wait()
end

if game.Name ~= "defaults-place.rbxlx" then
return false
end

return true
end

if not isDefaultsPlace() then
return
end

Expand Down

0 comments on commit d139189

Please sign in to comment.