Creating a C/C++/Rust Extension
What is an Extension?
An extension is a simple .dll/.so file that extends the functionality of gluapack with custom code.
One common use case for this is applying Lua obfuscators to your Lua files.
You can do this in any language you like - as long as it can be compiled as a .dll module or .so shared library.
This guide expects you to understand systems programming in your language of choice. I cannot help you learn a language, and I can't provide support for this, obviously. However, if you think something is broken, do let me know of course. If you have any basic questions about the functions or documentation then do not hesitate to contact me.
How it works
Extensions are installed to garrysmod/lua/bin/gluapack/, if that folder doesn't exist, create it.
Your extension will be loaded when gluapack initializes. gluapack will then search your exports for two functions: gluapack_filter and gluapack_mutate. You don't have to define both functions; only one of them. Don't forget to turn off name mangling so gluapack can find your functions in the exports table.
gluapack_filter allows you to specify whether a clientside/shared file should be added to the gluapack pack file or not. If you return false, it'll be networked via vanilla Garry's Mod networking.
It is undefined behaviour to return a different value between auto refreshes. Don't do that.
gluapack_mutate allows you to change the path or contents of a clientside/shared Lua file that is being added to the gluapack pack file.
It is undefined behaviour to change the file path of a Lua file during an auto refresh. Don't do that.
An example in Rust
This example will:
- Prevent any Lua file with
filter_mein its path from being added to the gluapack pack file; it will be sent through Garry's Mod's vanilla networking instead - Rename any Lua file with
rename_mein its path tolua/autorun/client/rename_me_renamed.lua - Override the contents of any Lua file with
mutate_mein its path toprint('hello world!')
Licensing
Your extensions are your own work and may be used privately for commercial or personal use.
Please do not sell gluapack extensions. If you've made something cool, and want to sell it, get in touch and we can work something out.