From 2f1f979f44245f506f18afd921842479dc7217bf Mon Sep 17 00:00:00 2001 From: Joshua Piper <32164094+JoshPiper@users.noreply.github.com> Date: Thu, 13 Jan 2022 22:01:14 +0000 Subject: [PATCH] feat: Adds LUA.is_menu() --- gmod/src/lua/lua_state.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gmod/src/lua/lua_state.rs b/gmod/src/lua/lua_state.rs index 9a43b9c..9cd681b 100644 --- a/gmod/src/lua/lua_state.rs +++ b/gmod/src/lua/lua_state.rs @@ -35,6 +35,14 @@ impl LuaState { server } + /// Returns whether this is the menu Lua state or not. + pub unsafe fn is_menu(&self) -> bool { + self.get_global(crate::lua_string!("MENU_DLL")); + let menu = self.get_boolean(-1); + self.pop(); + menu + } + /// 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.