rglua

This is a crate that contains bindings for using the lua c api in garrysmod through bindings using the rust libloading library. Can be used for either binary modules or just manual injections into gmod, like with Autorun-rs
This works by finding a lua_shared.dll
file relative to the currently running program, so you need to make sure your file is either in GarrysMod/bin/
or GarrysMod/garrysmod/bin
for srcds servers. The library will panic if the file is not found.
More information on binary modules can be found on the garrysmod wiki: Creating Binary Modules and an example can be found at the bottom of this file.
Usage
Add this to your Cargo.toml
file
[]
= ["cdylib"] # This tells rust we want to create a .dll file that links to C code.
[]
= "0.7.0"
Building
After installing rust, just run cargo build --release
.
If you are targeting 32 bit make sure to install the toolchain and build to it:
Notes
- This will most likely not work on other platforms and I am not able to vouch/test them.
- The nature of this crate is super unsafe and sort of defeats the purpose of rust's safety because of the interfacing you require to unsafe C code and the nature of linking to them.
Example Module
Find another larger example at examples/is_even
use *;
pub extern
pub extern
Acknowledgements
garrysmod_common
This is heavily based off of garrysmod_common, in how we export the lua_shared functions and trying to replicate everything from the Lua C Api.