I’m wondering if there’s a way to transfer ‘self’ across multiple Modules allowing Functions to be accessed from wherever within a part of the ‘self’ ?
i.e.
MainModule [Sets all values up etc & requires other modules] > Module2 that has functions in > Module3 that also has functions within.
In your MainModule, you can require Module2 and Module3 and pass ‘self’ as an argument when calling their functions:
local Module2 = require(script.Module2)
local Module3 = require(script.Module3)
local self = {
-- your values and setup here
}
Module2.someFunction(self)
Module3.anotherFunction(self)
In Module2 and Module3, you can define your functions to accept ‘self’ as an argument:
local function someFunction(self)
-- access 'self' values here
end
return {
someFunction = someFunction
}
local function anotherFunction(self)
-- access 'self' values here
end
return {
anotherFunction = anotherFunction
}