Hooking in
Sethbeastalan
Join Date: 2011-05-05 Member: 97360Members
in Modding
I'm a C++/Java programmer mainly, so I'm trying to pick up Lua for the first time right now. It isn't too different, but one thing that I've been hearing about on these forums, but can't find much information on is 'hooking.' Apparently that's how you overwrite the source code without actually overwriting it (so you can still play the game normally, and so your work isn't lost when it updates).
I really don't know how this works, and was wondering where to look for more info, or if you could just tell me if it's only a few sentences.
I really don't know how this works, and was wondering where to look for more info, or if you could just tell me if it's only a few sentences.
Comments
If you want to hook into a table method, it pretty much looks the same:
That's how you would extend a function. If you want to overwrite it, just don't call the original function.
You might hear the terms pre- and post-hooks, which define where you call the original function. Pre-hooks call the original function after your additional code and post-hooks call the original function before your additional code (like in the example above).