| Crates.io | gluac-rs |
| lib.rs | gluac-rs |
| version | 0.1.3 |
| created_at | 2021-06-05 22:27:05.696036+00 |
| updated_at | 2021-06-23 18:15:40.874945+00 |
| description | Rust Crate for compiling Garry's Mod Lua into bytecode |
| homepage | |
| repository | https://github.com/WilliamVenner/gluac-rs |
| max_upload_size | |
| id | 406662 |
| size | 36,505 |
Compile Garry's Mod Lua into bytecode using Rust!
Add to your Cargo.toml file:
[dependencies]
gluac-rs = "*"
parking_lot supportThis crate supports the parking_lot Mutex, just add the parking_lot feature flag like so:
[dependencies]
gluac-rs = { version = "*", features = ["parking_lot"] }
// A utility macro for user-friendly generation of Lua-compatible CStrings.
use gluac::lua_string;
// The instance of our bytecode compiler. This internally creates and prepares a Lua state and closes it when dropped.
let compiler: BytecodeCompiler = gluac::compiler();
// Compiling a Lua source code string
let result: Result<Vec<u8>, BytecodeError> = compiler.compile_string(lua_string!(r#"print("Hello, world!")"#));
...
// Compiling a file
let result: Result<Vec<u8>, BytecodeError> = compiler.compile_file(lua_string!(r#"path/to/file.lua"#));
...
This crate requires a few dependencies to be in the same directory as the executable.
You can find these libraries in your Garry's Mod installation, they appear to pop up in a number of different paths on different platforms and branches, so here's all the ones I know of:
bin/bin/win64bin/linux32bin/linux64garrysmod/binTake care to use the correct dependencies for your target branch of the game (32-bit/64-bit)
lua_shared.dlltier0.dllvstdlib.dllYou may also need to add the directory to the LD_LIBRARY_PATH environment variable.
lua_shared.solibtier0.solibvstdlib.solibsteam_api.so (32-bit only)I think older Garry's Mod versions have _srv suffixes in the file names for these libraries. These are also supported.
Willox - base code for Lua bindings and lua_shared loading
Mats - helping :D