Change to a game.Rojo module instead of _G

This commit is contained in:
boatbomber 2023-09-04 08:22:58 -07:00
parent b401b6db2f
commit 955b143ced

View file

@ -138,14 +138,14 @@ function App:init()
self.headlessAPI, self.readOnlyHeadlessAPI = HeadlessAPI.new(self) self.headlessAPI, self.readOnlyHeadlessAPI = HeadlessAPI.new(self)
-- selene: allow(global_usage) local existingAPIModule = game:FindFirstChild("Rojo")
local existingAPI = _G.Rojo if existingAPIModule and existingAPIModule:IsA("ModuleScript") then
if existingAPI then local existingAPI = require(existingAPIModule :: ModuleScript)
local responseEvent = Instance.new("BindableEvent") local responseEvent = Instance.new("BindableEvent")
responseEvent.Event:Once(function(accepted) responseEvent.Event:Once(function(accepted)
if accepted then if accepted then
-- selene: allow(global_usage) existingAPI.API = self.readOnlyHeadlessAPI
_G.Rojo = self.readOnlyHeadlessAPI -- Expose headless to other plugins and command bar
end end
responseEvent:Destroy() responseEvent:Destroy()
@ -163,7 +163,7 @@ function App:init()
responseEvent:Fire(false) responseEvent:Fire(false)
end, end,
content = e(ConflictAPIPopup, { content = e(ConflictAPIPopup, {
existingAPI = existingAPI, existingAPI = existingAPI.API,
onAccept = function() onAccept = function()
responseEvent:Fire(true) responseEvent:Fire(true)
end, end,
@ -176,8 +176,15 @@ function App:init()
return state return state
end) end)
else else
-- selene: allow(global_usage) local ExposedAPIModule = Instance.new("ModuleScript")
_G.Rojo = self.readOnlyHeadlessAPI -- Expose headless to other plugins and command bar ExposedAPIModule.Name = "Rojo"
ExposedAPIModule.Archivable = false
ExposedAPIModule.Source = "return { API = nil }"
local ExposedAPI = require(ExposedAPIModule)
ExposedAPI.API = self.readOnlyHeadlessAPI
ExposedAPIModule.Parent = game
end end
if if