[DiscordArchive] if its global, how would i then make some other function run after executing it?
[DiscordArchive] if its global, how would i then make some other function run after executing it?
Archived author: Grandold • Posted: 2022-04-21T13:32:31.601000+00:00
Original source
if its global, how would i then make some other function run after executing it?
Archived author: Grandold • Posted: 2022-04-21T13:32:42.668000+00:00
Original source
just trying to get the basic idea
Archived author: Foe • Posted: 2022-04-21T13:32:57.960000+00:00
Original source
Let me get on the pc instead of phone lol
Archived author: Grandold • Posted: 2022-04-21T13:33:03.257000+00:00
Original source
x)
Archived author: Foe • Posted: 2022-04-21T13:36:49.573000+00:00
Original source
```Lua
local function functionXYZ()
-- do stuff
end
local origFunctionA = FunctionA;
FunctionA = function(...)
origFunctionA(...);
functionXYZ()
end```
Archived author: Foe • Posted: 2022-04-21T13:37:35.771000+00:00
Original source
you create a local copy of the global function, then you overwrite the global function with your own function definition. You then call the local copy of the old global function, then run your own code
Archived author: Grandold • Posted: 2022-04-21T13:37:40.190000+00:00
Original source
aaahhh ye ofc, didnt realize it would be that simple lol
Archived author: Foe • Posted: 2022-04-21T13:38:13.839000+00:00
Original source
Load order is important however
Archived author: Grandold • Posted: 2022-04-21T13:39:02.890000+00:00
Original source
what if the functionA() was local? would I still be able to require it in moduleB.lua and use it then in same way?
Archived author: Foe • Posted: 2022-04-21T13:39:14.971000+00:00
Original source
No