Merge branch 'master' of https://github.com/WilliamVenner/gmod-rs
This commit is contained in:
commit
e9ef9e0978
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "printing-to-console"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
gmod = {version = "10.2.1", features = ["gmcl"], default-features = false}
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Printing to Console Example
|
||||||
|
|
||||||
|
This is an example of using a module to print to console.
|
||||||
|
Compiling should follow the instructions in [my-first-binary-module](../my-first-binary-module/README.md).
|
|
@ -0,0 +1,2 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
|
@ -0,0 +1,29 @@
|
||||||
|
#![feature(c_unwind)]
|
||||||
|
|
||||||
|
use gmod::gmcl::override_stdout;
|
||||||
|
use gmod::lua::State;
|
||||||
|
|
||||||
|
#[macro_use] extern crate gmod;
|
||||||
|
|
||||||
|
#[gmod13_open]
|
||||||
|
fn gmod13_open(lua: State) -> i32 {
|
||||||
|
// Here, if this module is running on the client.
|
||||||
|
if lua.is_client() {
|
||||||
|
// We overwrite println! so it prints to the console.
|
||||||
|
override_stdout()
|
||||||
|
}
|
||||||
|
|
||||||
|
if lua.is_server() {
|
||||||
|
println!("Hello Server, this is a binary module!")
|
||||||
|
} else {
|
||||||
|
println!("Hello Client, this is a binary module!")
|
||||||
|
}
|
||||||
|
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
#[gmod13_close]
|
||||||
|
fn gmod13_close(lua: State) -> i32 {
|
||||||
|
println!("Goodbye from binary module!");
|
||||||
|
0
|
||||||
|
}
|
Loading…
Reference in New Issue