Skip to content

Commit

Permalink
Merge pull request #149 from bubshayz/bubshayz-patch-1
Browse files Browse the repository at this point in the history
Trove should support more object cleanup methods
  • Loading branch information
Sleitnick authored Nov 25, 2023
2 parents a7993f4 + 99cfa58 commit 57e58d1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/trove/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

local FN_MARKER = newproxy()
local THREAD_MARKER = newproxy()
local GENERIC_OBJECT_CLEANUP_METHODS = { "Destroy", "Disconnect", "destroy", "disconnect" }

local RunService = game:GetService("RunService")

Expand All @@ -22,10 +23,10 @@ local function GetObjectCleanupFunction(object, cleanupMethod)
elseif t == "RBXScriptConnection" then
return "Disconnect"
elseif t == "table" then
if typeof(object.Destroy) == "function" then
return "Destroy"
elseif typeof(object.Disconnect) == "function" then
return "Disconnect"
for _, genericCleanupMethod in GENERIC_OBJECT_CLEANUP_METHODS do
if typeof(object[genericCleanupMethod]) == "function" then
return genericCleanupMethod
end
end
end
error("Failed to get cleanup function for object " .. t .. ": " .. tostring(object), 3)
Expand Down

0 comments on commit 57e58d1

Please sign in to comment.