Giter VIP home page Giter VIP logo

rglua's Introduction

๐ŸŒ‘ rglua cratesio Build Status License github/Vurv78

This is a crate that allows interop with the (g)luajit c api as well as the source sdk through libloading and vtable bindings. You can then use these for binary modules or manually injected code, like with Autorun-rs

More information on binary modules can be found on the garrysmod wiki: Creating Binary Modules and examples can be found here.

Usage

If you are targeting 32 bit make sure to install the toolchain and build to it:

rustup target add i686-pc-windows-msvc
cargo build --target=i686-pc-windows-msvc

Comparison

There are actually a decent amount of libraries out there for gmod development. Here's a comparison and why you could use this one.

Library rglua rust-glua-sys gmod-rs gmrs
Full Lua C Api Bindings โœ”๏ธ โŒ โŒ โŒ
On Crates.io โœ”๏ธ โŒ โœ”๏ธ โŒ
Proc Macros โœ”๏ธ โŒ โœ”๏ธ โœ”๏ธ
Interfacing w/ Source SDK โœ”๏ธ โŒ โŒ โŒ
Returning Result<> from functions โœ”๏ธ โŒ โŒ โœ”๏ธ
Can be used on stable โœ”๏ธ โœ”๏ธ โŒ โœ”๏ธ
Real world examples โœ”๏ธ โŒ ใ€ฐ๏ธ โœ”๏ธ
Linux / OSX Support โœ”๏ธ โŒ โœ”๏ธ โœ”๏ธ
Github Stars ๐Ÿ˜ข ๐Ÿ‘ ๐Ÿ‘‘ ๐Ÿคทโ€โ™‚๏ธ

You can help with that last one ๐Ÿ˜‰

Acknowledgements

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.

rglua's People

Contributors

vurv78 avatar yogwoggf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rglua's Issues

Unresolved import for printgm! macro

No idea why rust is doing this... I can't even import printgm!... Oh well, I guess it isn't necessary for the project so I'll just leave an issue here for now. Of course it'll need to be resolved by the time I bother to get this on crates.io.

Future API

Maybe Engine, Lua State, etc can be unified into one "Gmod" state object. I don't know the extent of proc-macros but I hope this can happen.

Example clientside binary module

use rglua::prelude::*;

// Either #[rglua::open] or #[rglua::open(interfaces..)]
// In this case, it tries to load the engine interface to add functions like is_connected
// Additionally maybe it can return a result?
#[rglua::open(engine)]
fn start_module(g: Gmod) -> i32 {
    printgm!(g, "{}", g.is_connected());
    0
}

#[rglua::close]
fn close_module(g: Gmod) -> i32 {
    0
}

cstring macro too unsafe

Might want an alternative that returns "" instead of panicking or see if there's a better way to go about it. Right now there's way too many crashes from it and I don't really know why.

Use libloading

Has much less dependencies I think & we don't need all of the extra stuff that dlopen provides.

Lua hook support

Something like

#[lua_hook("Think")]
fn think() {}

Which would be called inside gmod13_open, would register a hook like:

hook.Add("Think", "module." .. file!() .. ".rs", think_fn)

Make panics also exit gracefully, like in #10

Should be pretty easy to do with std::panic::catch_unwind and std::panic::set_hook.

This is sort of related to #10, although instead there it openly .unwrap()s so it is our fault that it kills the program.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.