added a function to determine if a script contains OnActivate

new-script-api
rexelion 7 years ago
parent ae14aa0c84
commit 1ee5dcff77

@ -42,6 +42,10 @@ namespace MWBase
///< Compile script with the given namen ///< Compile script with the given namen
/// \return Success? /// \return Success?
virtual bool hasOnActivate (const std::string& name) = 0;
///< Determine if a script with the given name contains OnActivate
/// \return Contains OnActivate?
virtual std::pair<int, int> compileAll() = 0; virtual std::pair<int, int> compileAll() = 0;
///< Compile all scripts ///< Compile all scripts
/// \return count, success /// \return count, success

@ -88,6 +88,12 @@ namespace MWScript
return false; return false;
} }
bool ScriptManager::hasOnActivate(const std::string& name)
{
const ESM::Script *script = mStore.get<ESM::Script>().find(name);
return script->mScriptText.find("OnActivate");
}
void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext) void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext)
{ {
// compile script // compile script

@ -62,6 +62,10 @@ namespace MWScript
///< Compile script with the given namen ///< Compile script with the given namen
/// \return Success? /// \return Success?
virtual bool hasOnActivate(const std::string& name);
///< Determine if a script with the given name contains OnActivate
/// \return Contains OnActivate?
virtual std::pair<int, int> compileAll(); virtual std::pair<int, int> compileAll();
///< Compile all scripts ///< Compile all scripts
/// \return count, success /// \return count, success

Loading…
Cancel
Save