Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for game.Name to change before running rbx-reflector plugin #449

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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