Esempio n. 1
0
bool Creature::click(Object *triggerer) {
	// Try the onDialog script first
	if (hasScript(kScriptDialogue))
		return runScript(kScriptDialogue, this, triggerer);

	// Next, look we have a generic onClick script
	if (hasScript(kScriptClick))
		return runScript(kScriptClick, this, triggerer);

	return false;
}
Esempio n. 2
0
bool Creature::click(Object *triggerer) {
	// Try the onDialog script first
	if (hasScript(kScriptDialogue))
		return runScript(kScriptDialogue, this, triggerer);

	// Next, look we have a generic onClick script
	if (hasScript(kScriptClick))
		return runScript(kScriptClick, this, triggerer);

	// Lastly, try to start a conversation directly
	return beginConversation(triggerer);
}
Esempio n. 3
0
File: init.c Progetto: Zoxc/gltron
void initVideo(void) {
	videoInit();
	runScript(PATH_SCRIPTS, "video.lua");

	initVideoData();

	consoleInit();
	initArtpacks();
	runScript(PATH_SCRIPTS, "menu.lua");
	runScript(PATH_SCRIPTS, "menu_functions.lua");
  setupDisplay(gScreen);
}
Esempio n. 4
0
void HTMLWidget::mouseModeChanged(const MouseModes mouseMode)
{
    const bool inSelectionMode = (mouseMode == MouseModeRegionSelection);

    if (inSelectionMode)
    {
        d->firstSelectionPoint.clear();
        d->intermediateSelectionPoint.clear();
        runScript(QString::fromLatin1("kgeomapSelectionModeStatus(%1);").arg(inSelectionMode));
    }
    else
    {
        runScript(QString::fromLatin1("kgeomapSelectionModeStatus(%1);").arg(inSelectionMode));
    }
}
Esempio n. 5
0
void HTMLWidget::setSelectionRectangle(const GeoCoordinates::Pair& searchCoordinates)
{
    if (!searchCoordinates.first.hasCoordinates())
    {
        runScript(QString::fromLatin1("kgeomapRemoveSelectionRectangle();"));
        return;
    }

    qreal West  = searchCoordinates.first.lon();
    qreal North = searchCoordinates.first.lat();
    qreal East  = searchCoordinates.second.lon();
    qreal South = searchCoordinates.second.lat();

    runScript(QString::fromLatin1("kgeomapSetSelectionRectangle(%1, %2, %3, %4);").arg(West).arg(North).arg(East).arg(South));
}
Esempio n. 6
0
void ScriptConsole::createDialogContent()
{
	ui->setupUi(dialog);
	connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));

	highlighter = new StelScriptSyntaxHighlighter(ui->scriptEdit->document());
	ui->includeEdit->setText(StelFileMgr::getInstallationDir() + "/scripts");

	ui->quickrunCombo->addItem(q_("quickrun..."));
	ui->quickrunCombo->addItem(q_("selected text"));
	ui->quickrunCombo->addItem(q_("clear text"));
	ui->quickrunCombo->addItem(q_("clear images"));
	ui->quickrunCombo->addItem(q_("natural"));
	ui->quickrunCombo->addItem(q_("starchart"));

	connect(ui->scriptEdit, SIGNAL(cursorPositionChanged()), this, SLOT(rowColumnChanged()));
	connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
	connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
	connect(ui->loadButton, SIGNAL(clicked()), this, SLOT(loadScript()));
	connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveScript()));
	connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearButtonPressed()));
	connect(ui->preprocessSSCButton, SIGNAL(clicked()), this, SLOT(preprocessScript()));
	connect(ui->runButton, SIGNAL(clicked()), this, SLOT(runScript()));
	connect(ui->stopButton, SIGNAL(clicked()), &StelApp::getInstance().getScriptMgr(), SLOT(stopScript()));
	connect(ui->includeBrowseButton, SIGNAL(clicked()), this, SLOT(includeBrowse()));
	connect(ui->quickrunCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(quickRun(int)));
	connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptRunning()), this, SLOT(scriptStarted()));
	connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptStopped()), this, SLOT(scriptEnded()));
	connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptDebug(const QString&)), this, SLOT(appendLogLine(const QString&)));
	connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptOutput(const QString&)), this, SLOT(appendOutputLine(const QString&)));
	ui->tabs->setCurrentIndex(0);
	ui->scriptEdit->setFocus();
}
Esempio n. 7
0
void ProgramExec::runScripts(ProgramList::iterator first, ProgramList::iterator last) {
	if (g_engineFlags & kEnginePauseJobs) {
		return;
	}

	for (ProgramList::iterator it = first; it != last; ++it) {

		AnimationPtr a = (*it)->_anim;

		if (a->_flags & kFlagsCharacter)
			a->resetZ();

		if ((a->_flags & kFlagsActing) == 0)
			continue;

		runScript(*it, a);

		if (a->_flags & kFlagsCharacter)
			a->resetZ();
	}

	_modCounter++;

	return;
}
Esempio n. 8
0
ScriptEditor::ScriptEditor(QWidget *parent)
    : EditWindow(parent)
{
    runAct = new QAction(QIcon(":/images/media-play-3x.png"), tr("&Run"), this);
//    runAct->setShortcuts(QKeySequence::New);
    runAct->setStatusTip(tr("Run script"));
    connect(runAct, SIGNAL(triggered()), this, SLOT(runScript()));

    runSelectionAct = new QAction(QIcon(":/images/reload-2x.png"),tr("Run se&lection"), this);
    runSelectionAct->setStatusTip(tr("Run selected text"));
    connect(runSelectionAct,SIGNAL(triggered()),this, SLOT(runSelection()));

    stopScriptAct = new QAction("STOP",this);
//    connect(stopScriptAct,SIGNAL(triggered()),SessionManager::instance(),SLOT(stop()));
    pauseAct = new QAction("PAUSE",this);
//    connect(pauseAct,SIGNAL(triggered()),SessionManager::instance(),SLOT(pause()));
//    connect(SessionManager::instance(),SIGNAL(isPaused(bool)),this,SLOT(showPauseState(bool)));

    runToolBar = addToolBar(tr("Run"));
    runToolBar->addAction(runAct);
    runToolBar->addAction(runSelectionAct);
//    runToolBar->addAction(pasteAct);


}
Esempio n. 9
0
void ScummEngine_v7::setCameraAt(int pos_x, int pos_y) {
	Common::Point old;

	old = camera._cur;

	camera._cur.x = pos_x;
	camera._cur.y = pos_y;

	clampCameraPos(&camera._cur);

	camera._dest = camera._cur;
	VAR(VAR_CAMERA_DEST_X) = camera._dest.x;
	VAR(VAR_CAMERA_DEST_Y) = camera._dest.y;

	assert(camera._cur.x >= (_screenWidth / 2) && camera._cur.y >= (_screenHeight / 2));

	if (camera._cur.x != old.x || camera._cur.y != old.y) {
		if (VAR(VAR_SCROLL_SCRIPT)) {
			VAR(VAR_CAMERA_POS_X) = camera._cur.x;
			VAR(VAR_CAMERA_POS_Y) = camera._cur.y;
			runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
		}

		// Even though cameraMoved() is called automatically, we may
		// need to know at once that the camera has moved, or text may
		// be printed at the wrong coordinates. See bugs #795938 and
		// #929242
		cameraMoved();
	}
}
Esempio n. 10
0
File: lua.cpp Progetto: Xackery/ZEQ
void Lua::initDatabase()
{
    if (!runScript(LUA_INIT_DB_PATH))
    {
        //throw
    }
}
Esempio n. 11
0
Task::ReportResult ScriptTask::report() {
    if (isMainThreadScript()) {
        QScriptEngine engine;
        result = runScript(&engine, conf.inputParametersMap, scriptText, stateInfo);
    }
    return ReportResult_Finished;
}
Esempio n. 12
0
MHWD::STATUS Mhwd::installConfig(std::shared_ptr<Config> config)
{
    std::string databaseDir;
    if ("USB" == config->type_)
    {
        databaseDir = MHWD_USB_DATABASE_DIR;
    }
    else
    {
        databaseDir = MHWD_PCI_DATABASE_DIR;
    }

    if (!runScript(config, MHWD::TRANSACTIONTYPE::INSTALL))
    {
        return MHWD::STATUS::ERROR_SCRIPT_FAILED;
    }

    if (!copyDirectory(config->basePath_, databaseDir + "/" + config->name_))
    {
        return MHWD::STATUS::ERROR_SET_DATABASE;
    }

    // Installed config vectors have to be updated manual with updateInstalledConfigData(Data*)

    return MHWD::STATUS::SUCCESS;
}
Esempio n. 13
0
static void activate(int val)
{
	if (self->active == TRUE)
	{
		runScript(self->requires);
	}
}
Esempio n. 14
0
static void activate(int val)
{
	if (self->head->active == FALSE)
	{
		runScript("rusted");
	}

	else
	{
		self->head->action = &fire;

		setEntityAnimation(self->head, "WALK");

		self->head->frameSpeed = 1;

		setCustomAction(&player, &invulnerableNoFlash, 60, 0, 0);

		setPlayerStunned(60);

		player.dirX = 12;
		player.dirY = -22;

		self->head->thinkTime = 120;
	}
}
ScriptValue WorkerContextExecutionProxy::evaluate(const String& script, const String& fileName, int baseLine, WorkerContextExecutionState* state)
{
    v8::HandleScope hs;

    initContextIfNeeded();
    v8::Context::Scope scope(m_context);

    v8::TryCatch exceptionCatcher;

    v8::Local<v8::String> scriptString = v8ExternalString(script);
    v8::Handle<v8::Script> compiledScript = V8Proxy::compileScript(scriptString, fileName, baseLine);
    v8::Local<v8::Value> result = runScript(compiledScript);

    if (exceptionCatcher.HasCaught()) {
        v8::Local<v8::Message> message = exceptionCatcher.Message();
        state->hadException = true;
        state->exception = ScriptValue(exceptionCatcher.Exception());
        state->errorMessage = toWebCoreString(message->Get());
        state->lineNumber = message->GetLineNumber();
        state->sourceURL = toWebCoreString(message->GetScriptResourceName());
        exceptionCatcher.Reset();
    } else
        state->hadException = false;

    if (result.IsEmpty() || result->IsUndefined())
        return ScriptValue();

    return ScriptValue(result);
}
Esempio n. 16
0
static void activate(int val)
{
	if (self->active == TRUE)
	{
		if (self->health == 0)
		{
			runScript("puzzle_pieces");
		}

		if (self->health == 1)
		{
			if (self->target->mental == 0)
			{
				self->target->mental = -2;
			}

			self->mental = 0;

			setInfoBoxMessage(300, 255, 255, 255, _("Solve the jigsaw puzzle"));

			self->target->requires[0] = '\0';

			self->action = &readInputCode;

			self->touch = NULL;

			self->activate = NULL;

			setPlayerLocked(TRUE);
		}
	}
}
Esempio n. 17
0
static void activate(int val)
{
    if (self->active == TRUE)
    {
        runScript("hidden_passage");
    }
}
Esempio n. 18
0
	void LuaSystem::processEntity(Entity &entity)
	{
		LuaComponent *luaComp = entity.getComponent<LuaComponent>();

		// Call lua script as usual
		if(luaComp->runningStatus == LuaComponent::Running)
		{

			lua_State *state = m_luaEnv.getRaw();

			// Call update function
			lua_getglobal(state, "update");

			// Push self
			LuaEnvironment::pushObjectToLua<Entity>(state, &entity, "jl.Entity");

			// Push delta time as argument TODO
			lua_pushnumber(state, game->getWindow().getDelta());

			if(!lua_isnil(state, -2))
			{
				if(lua_pcall(state, 2, 0, 0))
					m_luaEnv.reportError();
			}
		}

		// Only run Lua file if it's not loaded and has no errors, otherwise a reload is needed
		else if(!luaComp->runningStatus == LuaComponent::NotLoaded && !luaComp->runningStatus == LuaComponent::Errors)
			runScript(entity);
		
	}
Esempio n. 19
0
        TEST_F(JSDeviceTest, getEndpoints) {
            EndpointID endpointId1{20};
            EndpointID endpointId2{21};
            ZEndpoint endpoint1{NwkAddr {1}, endpointId1, 30, 31, 32, {ClusterID {50}}, {ClusterID {51}}};
            ZEndpoint endpoint2{NwkAddr {1}, endpointId2, 30, 31, 32, {ClusterID {60}}, {ClusterID {61}}};
            ZDevice zDevice{extAddress, NwkAddr(1), 0, {endpoint1, endpoint2}};
            V8_SETUP

            Local<Object> objectEndpoint1 = Object::New(isolate);
            Local<Object> objectEndpoint2 = Object::New(isolate);

            EXPECT_CALL(*zDevices, exists(extAddress)).WillOnce(Return(true));

            EXPECT_CALL(*zDevices, getDevice(extAddress)).WillOnce(Return(&zDevice));
            EXPECT_CALL(*jsEndpoint, createInstance(isolate, extAddress, endpointId1)).WillOnce(
                    Return(objectEndpoint1));
            EXPECT_CALL(*jsEndpoint, createInstance(isolate, extAddress, endpointId2)).WillOnce(
                    Return(objectEndpoint2));

            v8::Local<v8::Value> result = runScript(creatingZDeviceScript + "a.getEndpoints();");
            ASSERT_THAT(result.IsEmpty(), false);
            ASSERT_THAT(result->IsArray(), true);
            Local<Array> array = result.As<Array>();

            ASSERT_THAT(array->Length(), 2);
            ASSERT_THAT(array->Get(0)->IsObject(), true);
            ASSERT_THAT(array->Get(1)->IsObject(), true);
            Local<Object> jszEndpoint0 = array->Get(0).As<Object>();
            Local<Object> jszEndpoint1 = array->Get(1).As<Object>();
            ASSERT_THAT(jszEndpoint0->GetIdentityHash(), Eq(objectEndpoint1->GetIdentityHash()));
            ASSERT_THAT(jszEndpoint1->GetIdentityHash(), Eq(objectEndpoint2->GetIdentityHash()));
        }
Esempio n. 20
0
DWORD WINAPI LuaThread(LPVOID pParam)
{
	runScript((char*) pParam, 0);
	unloadMikmod();
	exit(0);
	return 0;
}
Esempio n. 21
0
v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* node)
{
    ASSERT(v8::Context::InContext());

    v8::Local<v8::Value> result;
    {
        // Isolate exceptions that occur when compiling and executing
        // the code. These exceptions should not interfere with
        // javascript code we might evaluate from C++ when returning
        // from here.
        v8::TryCatch tryCatch;
        tryCatch.SetVerbose(true);

        // Compile the script.
        v8::Local<v8::String> code = v8ExternalString(source.source());
        ChromiumBridge::traceEventBegin("v8.compile", node, "");

        // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at
        // 1, whereas v8 starts at 0.
        v8::Handle<v8::Script> script = compileScript(code, source.url(), source.startLine() - 1);
        ChromiumBridge::traceEventEnd("v8.compile", node, "");

        ChromiumBridge::traceEventBegin("v8.run", node, "");
        // Set inlineCode to true for <a href="javascript:doSomething()">
        // and false for <script>doSomething</script>. We make a rough guess at
        // this based on whether the script source has a URL.
        result = runScript(script, source.url().string().isNull());
    }
    ChromiumBridge::traceEventEnd("v8.run", node, "");
    return result;
}
Esempio n. 22
0
bool NPCScript::callFunction(NPCFunction function)
{
   if(functionExists[function])
   {
      // Load the table of Lua functions for this NPC
      lua_getglobal(luaStack, scriptName.c_str());

      // Grab the function name
      const char* functionName = FUNCTION_NAMES[function];

      DEBUG("NPC %s running function %s", npc->getName().c_str(), functionName);

      // Get the function from the NPC function table and push it on the stack
      lua_pushstring(luaStack, functionName);
      lua_gettable(luaStack, -2);

      // Push NPC as argument
      luaW_push<Actor>(luaStack, npc);

      // Run the script
      return runScript(1);
   }

   return true;
}
Esempio n. 23
0
bool Placeable::click(Object *triggerer) {
	// If the door has a used script, call that
	if (hasScript(kScriptUsed))
		return runScript(kScriptUsed, this, triggerer);

	return true;
}
Esempio n. 24
0
bool NPCScript::resume(long timePassed)
{
   if(finished) return true;
   
   if(activated)
   {
      activated = false;
      callFunction(ACTIVATE);
   }

   if(running)
   {
      DEBUG("NPC Thread %d resuming running script.", getId());
      runScript();
   }
   else
   {
      if(npc->isIdle())
      {
         callFunction(IDLE);
      }
   }

   return false;
}
Esempio n. 25
0
MHWD::STATUS Mhwd::uninstallConfig(Config *config)
{
    std::shared_ptr<Config> installedConfig{getInstalledConfig(config->name_, config->type_)};

    // Check if installed
    if (nullptr == installedConfig)
    {
        return MHWD::STATUS::ERROR_NOT_INSTALLED;
    }
    else if (installedConfig->basePath_ != config->basePath_)
    {
        return MHWD::STATUS::ERROR_NO_MATCH_LOCAL_CONFIG;
    }
    else
    {
        // TODO: Should we check for local requirements here?

        // Run script
        if (!runScript(installedConfig, MHWD::TRANSACTIONTYPE::REMOVE))
        {
            return MHWD::STATUS::ERROR_SCRIPT_FAILED;
        }

        if (!removeDirectory(installedConfig->basePath_))
        {
            return MHWD::STATUS::ERROR_SET_DATABASE;
        }

        // Installed config vectors have to be updated manual with updateInstalledConfigData(Data*)

        return MHWD::STATUS::SUCCESS;
    }
}
Esempio n. 26
0
void ComposerEngine::onKeyDown(uint16 keyCode) {
	runEvent(kEventKeyDown, keyCode, 0, 0);
	runEvent(kEventChar, keyCode, 0, 0);

	for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++) {
		for (Common::List<KeyboardHandler>::iterator j = i->_keyboardHandlers.begin(); j != i->_keyboardHandlers.end(); j++) {
			const KeyboardHandler &handler = *j;
			if (keyCode != handler.keyId)
				continue;

			int modifiers = g_system->getEventManager()->getModifierState();
			switch (handler.modifierId) {
			case 0x10: // shift
				if (!(modifiers & Common::KBD_SHIFT))
					continue;
				break;
			case 0x11: // control
				if (!(modifiers & Common::KBD_CTRL))
					continue;
				break;
			case 0:
				break;
			default:
				warning("unknown keyb modifier %d", handler.modifierId);
				continue;
			}

			runScript(handler.scriptId);
		}
	}
}
Esempio n. 27
0
  void LuaScriptSystem::updateComponent(ScriptComponent* component, Entity* entity, const double& time)
  {
    if(!component->getSetupExecuted())
    {
      runFunction(component, component->getSetupFunction());
      LOG(INFO) << entity->getId() << " executing script";
      runScript(component, component->getSetupScript());
      component->setSetupExecuted(true);
    }

    if(!component->getBehavior().empty() && component->getBtree() == sol::lua_nil) {
      sol::function initializeBtree = (*mState)["btree"]["initialize"].get<sol::function>();
      sol::table btree = initializeBtree(component->getOwner()->getId(), component->getBehavior());
      component->setBtree(btree);
      sol::table context = btree["context"];

      component->setData(context);

      LOG(INFO) << "Successfuly registered script component for entity " << component->getOwner()->getId();
    }

    if(component->hasBehavior())
    {
      sol::table& btree = component->getBtree();
      btree["update"](btree, time);
    }
  }
Esempio n. 28
0
File: init.c Progetto: Zoxc/gltron
void initAudio(void) {
	
	audioInit();
	runScript(PATH_SCRIPTS, "audio.lua");
  /* probe for artpacks & songs */
  Sound_initTracks();
  Sound_setup();
}
Esempio n. 29
0
void Module::leave() {
	runScript(kScriptExit, this, _pc);

	_running = false;
	_exit    = true;

	unloadPC();
}
Esempio n. 30
0
//! [3]
void Window::runInDebugger()
{
    QListWidgetItem *item = m_view->currentItem();
    if (item) {
        QString fileName = item->text();
        runScript(fileName, /*debug=*/true);
    }
}