Skip to content

Commit

Permalink
Connect a BindableFunction to all imported module functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hoontee committed Jan 22, 2025
1 parent 5094c87 commit 5946213
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Pronghorn/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
║ ██████▀██▓▌▀▌ ▄ ▄▓▌▐▓█▌ ║
║ ║
║ ║
║ Pronghorn Framework Rev. B85
║ Pronghorn Framework Rev. B86
║ https://github.com/Iron-Stag-Games/Pronghorn ║
║ GNU Lesser General Public License v2.1 ║
║ ║
Expand Down Expand Up @@ -128,6 +128,28 @@ function Pronghorn:Import(paths: {Instance}): ()
addModules(allModules, object)
end

-- Bindable functions
for _, moduleTable in allModules do
if type(moduleTable.Return) == "table" then
for key, value in moduleTable.Return do
if
type(value) == "function"
and key ~= "Init"
and key ~= "Deferred"
and key ~= "PlayerAdded"
and key ~= "PlayerAddedDeferred"
and key ~= "PlayerRemoving"
and key ~= "PlayerRemovingDeferred"
then
local bindableFunction = moduleTable.Object:FindFirstChild(key) :: Instance?
(if bindableFunction and bindableFunction:IsA("BindableFunction") then bindableFunction else New.Instance("BindableFunction", moduleTable.Object, key)).OnInvoke = function(...: any): ()
moduleTable.Return[key](moduleTable.Return, ...)
end
end
end
end
end

-- Init
for _, moduleTable in allModules do
if type(moduleTable.Return) == "table" and moduleTable.Return.Init then
Expand Down

0 comments on commit 5946213

Please sign in to comment.