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

Commit bc0e77b

Browse files
committed
README changes
Removed a lot of clutter, link to example so I don't have to update the version every tiny commit.
1 parent bd5c02b commit bc0e77b

File tree

2 files changed

+10
-43
lines changed

2 files changed

+10
-43
lines changed

README.md

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,17 @@
1-
# rglua [![cratesio](https://img.shields.io/crates/v/rglua.svg)](https://crates.io/crates/rglua) ![Build Status](https://www.travis-ci.com/Vurv78/rglua.svg?branch=main) [![License](https://img.shields.io/github/license/Vurv78/rglua?color=red)](https://opensource.org/licenses/Apache-2.0) [![github/Vurv78](https://img.shields.io/discord/824727565948157963?label=Discord&logo=discord&logoColor=ffffff&labelColor=7289DA&color=2c2f33)](https://discord.gg/epJFC6cNsw)
1+
# 🌑 ``rglua`` [![cratesio](https://img.shields.io/crates/v/rglua.svg)](https://crates.io/crates/rglua) ![Build Status](https://www.travis-ci.com/Vurv78/rglua.svg?branch=main) [![License](https://img.shields.io/github/license/Vurv78/rglua?color=red)](https://opensource.org/licenses/Apache-2.0) [![github/Vurv78](https://img.shields.io/discord/824727565948157963?label=Discord&logo=discord&logoColor=ffffff&labelColor=7289DA&color=2c2f33)](https://discord.gg/epJFC6cNsw)
22

33
This is a crate that contains bindings for using the lua c api in garrysmod through bindings using the rust libloading library.
44
Can be used for either binary modules or just manual injections into gmod, like with [Autorun-rs](https://github.com/Vurv78/Autorun-rs)
55

66
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.
77

8-
More information on binary modules can be found on the garrysmod wiki: [Creating Binary Modules](https://wiki.facepunch.com/gmod/Creating_Binary_Modules) and an example can be found at the bottom of this file.
9-
8+
More information on binary modules can be found on the garrysmod wiki: [Creating Binary Modules](https://wiki.facepunch.com/gmod/Creating_Binary_Modules) and an example [can be found here.](https://github.com/Vurv78/rglua/tree/master/examples/is_even)
109
## Usage
11-
12-
Add this to your ``Cargo.toml`` file
13-
```toml
14-
[lib]
15-
crate-type = ["cdylib"] # This tells rust we want to create a .dll file that links to C code.
16-
17-
[dependencies]
18-
rglua = "0.7.0"
19-
```
20-
21-
## Building
22-
After [installing rust](https://www.rust-lang.org/tools/install), just run ``cargo build --release``.
23-
2410
If you are targeting 32 bit make sure to install the toolchain and build to it:
2511
```bash
2612
rustup target add i686-pc-windows-msvc
2713
cargo build --release --target=i686-pc-windows-msvc
2814
```
29-
30-
## Notes
31-
* This will most likely not work on other platforms and I am not able to vouch/test them.
32-
* 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.
33-
34-
## Example Module
35-
Find another larger example at examples/is_even
36-
```rust
37-
use rglua::prelude::*;
38-
39-
#[no_mangle]
40-
pub extern fn gmod13_open(state: LuaState) -> i32 {
41-
lua_getglobal(state, cstr!("print"));
42-
lua_pushstring(state, cstr!("Hello from rust!")); // Print to the in-game console
43-
lua_call(state, 1, 0);
44-
45-
// or
46-
printgm!(state, "Hello world!");
47-
0
48-
}
49-
50-
#[no_mangle]
51-
pub extern fn gmod13_close(_state: LuaState) -> i32 {
52-
0
53-
}
54-
```
55-
5615
## Acknowledgements
5716
### [garrysmod_common](https://github.com/danielga/garrysmod_common)
5817
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.

examples/is_even/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# 💻 ``is_even``
2+
Binary module that adds two functions to the existing ``math`` library.
3+
4+
## math.is_even(n: number)
5+
Returns ``true`` if the number is even, else false
6+
7+
## math.is_odd(n: number)
8+
Returns ``true`` if the number is odd, else false

0 commit comments

Comments
 (0)