From 3edcc91c72c96c33f8eae76a7078f78126bbea28 Mon Sep 17 00:00:00 2001 From: Rémy Raes Date: Thu, 4 Jul 2024 23:34:16 +0200 Subject: Expose mods remote status to Squirrel VM (#684) Add a Squirrel VM method to know if a given mod is remote or not. --- primedev/scripts/client/scriptmodmenu.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/primedev/scripts/client/scriptmodmenu.cpp b/primedev/scripts/client/scriptmodmenu.cpp index 2e877db4..5ffe0fdf 100644 --- a/primedev/scripts/client/scriptmodmenu.cpp +++ b/primedev/scripts/client/scriptmodmenu.cpp @@ -49,6 +49,23 @@ ADD_SQFUNC("void", NSSetModEnabled, "string modName, bool enabled", "", ScriptCo return SQRESULT_NULL; } +ADD_SQFUNC("bool", NSIsModRemote, "string modName", "", ScriptContext::SERVER | ScriptContext::CLIENT | ScriptContext::UI) +{ + const SQChar* modName = g_pSquirrel->getstring(sqvm, 1); + + // manual lookup, not super performant but eh not a big deal + for (Mod& mod : g_pModManager->m_LoadedMods) + { + if (!mod.Name.compare(modName)) + { + g_pSquirrel->pushbool(sqvm, mod.m_bIsRemote); + return SQRESULT_NOTNULL; + } + } + + return SQRESULT_NULL; +} + ADD_SQFUNC("string", NSGetModDescriptionByModName, "string modName", "", ScriptContext::SERVER | ScriptContext::CLIENT | ScriptContext::UI) { const SQChar* modName = g_pSquirrel->getstring(sqvm, 1); -- cgit v1.2.3