I’m trying to make a custom “connection” object class so that I can have a system that resembles bindable events without having to flood my game with a lot of random instances. So far, I have a basic system working in under 30 lines to connect functions and call them all through the connection, but now I want to try to pass parameters along.
Here’s the code I use to call connected functions when the event is triggered, where self.Functions is a table containing connected functions:
function Connection:Fire()
table.foreach(self.Functions,function(index) self.Functions[index]() end)
end
I want to modify it to pass a tuple from the input to the functions in the “Functions” tables, like this:
function Connection:Fire(...)
table.foreach(self.Functions,function(index) self.Functions[index](...) end)
end
I suppose I could take a table input and unpack it into the functions, but that seems a little messy to do, and learning how to work with tuples will also help me in the future with other functions that call functions.