void Functions::executeScript(Aurora::NWScript::FunctionContext &ctx) { Common::UString script = ctx.getParams()[0].getString(); // Max resource name length is 16, and ExecuteScript should truncate accordingly script.truncate(16); if (!ResMan.hasResource(script, Aurora::kFileTypeNCS)) return; Aurora::NWScript::Object *object = getParamObject(ctx, 1); try { Aurora::NWScript::NCSFile ncs(script); // Let the child script inherit the environment of this parent script Aurora::NWScript::VariableContainer *env = ctx.getCurrentEnvironment(); if (env) ncs.setEnvironment(*env); ncs.run(object); } catch (Common::Exception &e) { e.add("Failed ExecuteScript(\"%s\", %s)", script.c_str(), Aurora::NWScript::formatTag(object).c_str()); Common::printException(e, "WARNING: "); } }
void Functions::getCurrentEvent(Aurora::NWScript::FunctionContext &ctx) { ctx.getReturn() = (const Aurora::NWScript::EngineType *) 0; Aurora::NWScript::VariableContainer *env = ctx.getCurrentEnvironment(); if (!env || !env->hasVariable("Event")) return; ctx.getReturn() = env->getVariable("Event"); }
void Functions::getCurrentEventType(Aurora::NWScript::FunctionContext &ctx) { ctx.getReturn() = (int32) kEventTypeInvalid; Aurora::NWScript::VariableContainer *env = ctx.getCurrentEnvironment(); if (!env || !env->hasVariable("Event")) return; const Event *event = DragonAge2::ObjectContainer::toEvent(env->getVariable("Event").getEngineType()); if (!event) return; ctx.getReturn() = (int32) event->getType(); }