Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[package]
name = "rglua"
description = "GLua bindings for rust."
description = "Rust bindings to the lua api for gmod binary module creation"
version = "0.1.0"
authors = ["Vurv <vurvdevelops@gmail.com>"]
build = "build.rs"
keywords = ["glua","garrysmod","lua"]
readme = "README.md"
license = "MIT"

# Remember to make your output module a cdylib.

[build-dependencies]
cc = "1.0.65"
[dependencies]
dlopen = { git = "https://github.com/Vurv78/rust-dlopen", branch = "future", features = ["derive"] }
once_cell = "1.7.2"
File renamed without changes.
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# rglua
![TravisCI Status](https://www.travis-ci.com/Vurv78/rglua.svg?branch=main)
# rglua ![TravisCI Status](https://www.travis-ci.com/Vurv78/rglua.svg?branch=main)

This is a Rust library that contains bindings for garrysmod binary module creation as well as more user-friendly interfaces to interact with lua states.
This is a Rust library that contains bindings for garrysmod binary module creation that gives you complete access to the lua c api through bindings from dlopen.
It uses rust-dlopen

More information on binary modules: https://wiki.facepunch.com/gmod/Creating_Binary_Modules

Expand All @@ -24,27 +24,33 @@ Make sure you build to 32 bit if you want to use the module with srcds / on a lo
Also do this if you have never compiled to 32 bit, to get rustup to install 32 bit versions of everything you need
``rustup target add i686-pc-windows-msvc``

More Info and example module (Not made with rglua): https://github.com/Vurv78/gmod-rust-test

Note:
I have never gotten anyone to test this on linux or OSX, It should work just fine however. Travis Ci Should give you an idea on how this runs on linux at least.
The nature of this crate is super unsafe.
Using rust sort of defeats the purpose because of the sheer amount of times you'll have to convert strings from and to C, and call lua c api functions.

Also, I have never tested this outside of Windows and won't. If there are any issues on other platforms, I will gladly accept any PRs you may make but I can't help you myself.

## Example Module
```rust
use rglua::{RLuaState,LuaState,printgm};
use rglua::{
types::{
LuaState
},
cstring,
LUA_SHARED
};

#[no_mangle]
unsafe extern fn gmod13_open(state: LuaState) -> i32 {
let mut wrapped = RLuaState::new(state);
// This is the same as doing 'printgm!(wrapped,"Hello from rust!")'
wrapped.get_global(&"print");
wrapped.push_string(&"Hello from rust!");
wrapped.call(1,0);
printgm!(wrapped,"Another way to say hello!");
pub extern fn gmod13_open(state: LuaState) -> i32 {
let shared = &*LUA_SHARED;
shared.lua_getglobal(state, cstring!("print") );
shared.lua_pushstring(state, cstring!("Hello from rust!") );
shared.lua_call(state, 1, 0);
0
}
#[no_mangle]
unsafe extern fn gmod13_close(state: LuaState) -> i32 {
let mut _wrapped = RLuaState::new(state);
}

#[no_mangle]
pub extern fn gmod13_close(_state: LuaState) -> i32 {
0
}
}
```
7 changes: 0 additions & 7 deletions build.rs

This file was deleted.

32 changes: 0 additions & 32 deletions glua-headers/Interface.h

This file was deleted.

103 changes: 0 additions & 103 deletions glua-headers/LuaBase.h

This file was deleted.

112 changes: 0 additions & 112 deletions glua-headers/Types.h

This file was deleted.

18 changes: 0 additions & 18 deletions glua-headers/UserData.h

This file was deleted.

Loading