Skip to content

Commit

Permalink
Expose mods remote status to Squirrel VM (#684)
Browse files Browse the repository at this point in the history
Add a Squirrel VM method to know if a given mod is remote or not.
  • Loading branch information
Alystrasz authored Jul 4, 2024
1 parent afa2469 commit 3edcc91
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions primedev/scripts/client/scriptmodmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<context>->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<context>->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<context>->getstring(sqvm, 1);
Expand Down

0 comments on commit 3edcc91

Please sign in to comment.