[DiscordArchive] Ye what I was thinking was that I have moduleA.lua with a function functionA(), and moduleB.lua with
[DiscordArchive] Ye what I was thinking was that I have moduleA.lua with a function functionA(), and moduleB.lua with
Archived author: Grandold • Posted: 2022-04-21T13:19:09.640000+00:00
Original source
Ye what I was thinking was that I have moduleA.lua with a function functionA(), and moduleB.lua with functionB().
Can I purely inside the code of moduleB.lua somehow force additional function to be ran, when functionA() of the moduleA.lue is executed?
Archived author: Grandold • Posted: 2022-04-21T13:21:29.042000+00:00
Original source
I would guess some kind of event listener would be required in the moduleB.lua, that would watch whenever functionA() in moduleA.lua is executed and that would then be able to run some other function that I define
Archived author: Grandold • Posted: 2022-04-21T13:22:25.858000+00:00
Original source
But yee just something that came into my mind as I was browsing some lua code and thinking if instead of modifying existing code I could just extend it
Archived author: Honey • Posted: 2022-04-21T13:23:34.616000+00:00
Original source
Oh we're talking about Lua Scripts, Not cpp modules.
Ofc you can execute Code in one lua File, which interacts with another one. Unless you use `local` ofc.
Archived author: Foe • Posted: 2022-04-21T13:25:25.998000+00:00
Original source
Yes, there's no problem writing something like that
Archived author: Grandold • Posted: 2022-04-21T13:25:47.429000+00:00
Original source
would that be done with some event listener or what would be the approach?
Archived author: Foe • Posted: 2022-04-21T13:25:53.532000+00:00
Original source
You can do a lot with the raw functions like packet events, methods, etc
Archived author: Foe • Posted: 2022-04-21T13:26:12.696000+00:00
Original source
Quite a lot of core functionality can be emulated in Lua without exposing any new methods
Archived author: Foe • Posted: 2022-04-21T13:28:22.349000+00:00
Original source
There's no post-event hook, so you'll have to keep it in mind whenever you write your modules. You can set up an event handler that registers events separately to the script itself, or you can override global functions with other functions. One way is to make a local copy of a global function, overwrite the global function with a new function, and within that new global you run the local copy first before your code
Archived author: Foe • Posted: 2022-04-21T13:28:35.100000+00:00
Original source
There's a lot of approaches you can take really ♂️