Attribute Macro gmod_open

Source
#[gmod_open]
Expand description

Creates the entrypoint to garrysmod. Compiles down to gmod13_open.

Normally you would not be able to return types other than i32 through to gmod13_open, this is still true, but this proc-macro allows it through unwrapping the result and containing attributes on a hidden generated function.

ยงExamples

use rglua::prelude::*;
#[gmod_open]
fn entry(state: LuaState) -> Result<i32, std::io::Error> {
    printgm!(state, "Hello, gmod!");
    std::fs::write("foo.txt", "bar")?;

    // We don't push objects to lua, so return 0 (# of returns)
    Ok(0)
}