diff --git a/Cargo.lock b/Cargo.lock index 5b4adbd..14a5a09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "gmod" -version = "10.2.0" +version = "10.2.1" dependencies = [ "cfg_table 1.0.0", "cstr", diff --git a/gmod/Cargo.toml b/gmod/Cargo.toml index 0481807..6fc0f90 100644 --- a/gmod/Cargo.toml +++ b/gmod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gmod" -version = "10.2.0" +version = "10.2.1" authors = ["William Venner "] edition = "2018" license = "MIT" diff --git a/gmod/src/lua/lua_state.rs b/gmod/src/lua/lua_state.rs index 37d93fb..9a43b9c 100644 --- a/gmod/src/lua/lua_state.rs +++ b/gmod/src/lua/lua_state.rs @@ -19,6 +19,22 @@ impl LuaState { } } + /// Returns whether this is the clientside Lua state or not. + pub unsafe fn is_client(&self) -> bool { + self.get_global(crate::lua_string!("CLIENT")); + let client = self.get_boolean(-1); + self.pop(); + client + } + + /// Returns whether this is the serverside Lua state or not. + pub unsafe fn is_server(&self) -> bool { + self.get_global(crate::lua_string!("SERVER")); + let server = self.get_boolean(-1); + self.pop(); + server + } + /// Returns the Lua string as a slice of bytes. /// /// **WARNING:** This will CHANGE the type of the value at the given index to a string.