You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 12, 2025. It is now read-only.
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
5
5
6
6
More information on binary modules: https://wiki.facepunch.com/gmod/Creating_Binary_Modules
7
7
@@ -24,27 +24,33 @@ Make sure you build to 32 bit if you want to use the module with srcds / on a lo
24
24
Also do this if you have never compiled to 32 bit, to get rustup to install 32 bit versions of everything you need
25
25
``rustup target add i686-pc-windows-msvc``
26
26
27
-
More Info and example module (Not made with rglua): https://github.com/Vurv78/gmod-rust-test
28
-
29
27
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.
31
32
32
33
## Example Module
33
34
```rust
34
-
userglua::{RLuaState,LuaState,printgm};
35
+
userglua::{
36
+
types::{
37
+
LuaState
38
+
},
39
+
cstring,
40
+
LUA_SHARED
41
+
};
42
+
35
43
#[no_mangle]
36
-
unsafeexternfngmod13_open(state:LuaState) ->i32 {
37
-
letmutwrapped=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
+
pubexternfngmod13_open(state:LuaState) ->i32 {
45
+
letshared=&*LUA_SHARED;
46
+
shared.lua_getglobal(state, cstring!("print") );
47
+
shared.lua_pushstring(state, cstring!("Hello from rust!") );
0 commit comments