Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 1777f36

Browse files
authored
Future (#2)
Completely changed how rglua will work. Nobody was using this so it's fine. See the commit changes
1 parent d6bdc1d commit 1777f36

14 files changed

Lines changed: 211 additions & 575 deletions

File tree

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[package]
22
name = "rglua"
3-
description = "GLua bindings for rust."
3+
description = "Rust bindings to the lua api for gmod binary module creation"
44
version = "0.1.0"
55
authors = ["Vurv <vurvdevelops@gmail.com>"]
6-
build = "build.rs"
76
keywords = ["glua","garrysmod","lua"]
87
readme = "README.md"
8+
license = "MIT"
99

1010
# Remember to make your output module a cdylib.
1111

12-
[build-dependencies]
13-
cc = "1.0.65"
12+
[dependencies]
13+
dlopen = { git = "https://github.com/Vurv78/rust-dlopen", branch = "future", features = ["derive"] }
14+
once_cell = "1.7.2"
File renamed without changes.

README.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# rglua
2-
![TravisCI Status](https://www.travis-ci.com/Vurv78/rglua.svg?branch=main)
1+
# rglua ![TravisCI Status](https://www.travis-ci.com/Vurv78/rglua.svg?branch=main)
32

4-
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.
3+
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.
4+
It uses rust-dlopen
55

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

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

27-
More Info and example module (Not made with rglua): https://github.com/Vurv78/gmod-rust-test
28-
2927
Note:
30-
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.
28+
The nature of this crate is super unsafe.
29+
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.
30+
31+
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.
3132

3233
## Example Module
3334
```rust
34-
use rglua::{RLuaState,LuaState,printgm};
35+
use rglua::{
36+
types::{
37+
LuaState
38+
},
39+
cstring,
40+
LUA_SHARED
41+
};
42+
3543
#[no_mangle]
36-
unsafe extern fn gmod13_open(state: LuaState) -> i32 {
37-
let mut wrapped = RLuaState::new(state);
38-
// This is the same as doing 'printgm!(wrapped,"Hello from rust!")'
39-
wrapped.get_global(&"print");
40-
wrapped.push_string(&"Hello from rust!");
41-
wrapped.call(1,0);
42-
printgm!(wrapped,"Another way to say hello!");
44+
pub extern fn gmod13_open(state: LuaState) -> i32 {
45+
let shared = &*LUA_SHARED;
46+
shared.lua_getglobal(state, cstring!("print") );
47+
shared.lua_pushstring(state, cstring!("Hello from rust!") );
48+
shared.lua_call(state, 1, 0);
4349
0
44-
}
45-
#[no_mangle]
46-
unsafe extern fn gmod13_close(state: LuaState) -> i32 {
47-
let mut _wrapped = RLuaState::new(state);
50+
}
51+
52+
#[no_mangle]
53+
pub extern fn gmod13_close(_state: LuaState) -> i32 {
4854
0
49-
}
55+
}
5056
```

build.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

glua-headers/Interface.h

Lines changed: 0 additions & 32 deletions
This file was deleted.

glua-headers/LuaBase.h

Lines changed: 0 additions & 103 deletions
This file was deleted.

glua-headers/Types.h

Lines changed: 0 additions & 112 deletions
This file was deleted.

glua-headers/UserData.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)