예제 #1
0
IPState DomeScript::Move(DomeDirection dir, DomeMotionCommand operation)
{
    if (operation == MOTION_START)
    {
        if (RunScript(dir == DOME_CW ? SCRIPT_MOVE_CW : SCRIPT_MOVE_CCW, nullptr))
        {
            DomeAbsPosNP.s = IPS_BUSY;
            TargetAz       = -1;
        }
        else
        {
            DomeAbsPosNP.s = IPS_ALERT;
        }
    }
    else
    {
        if (RunScript(SCRIPT_ABORT, nullptr))
        {
            DomeAbsPosNP.s = IPS_IDLE;
        }
        else
        {
            DomeAbsPosNP.s = IPS_ALERT;
        }
    }
    IDSetNumber(&DomeAbsPosNP, nullptr);
    return ((operation == MOTION_START) ? IPS_BUSY : IPS_OK);
}
예제 #2
0
bool Behavior::StartScript(NPC *npc, EventManager *eventmgr)
{
    if (interrupted && resume_after_interrupt)
    {
        npc->Printf(3,"Resuming behavior %s after interrupt at step %d - %s.",
                    name.GetData(), current_step, sequence[current_step]->GetName());
        interrupted = false;
        return RunScript(npc,eventmgr,true);
    }
    else
    {
        // Start at the first step of the script.
        current_step = 0;

        if (interrupted)
        {
            // We don't resume_after_interrupt, but the flag needs to be cleared
            npc->Printf(3,"Restarting behavior %s after interrupt at step %d - %s.",
                        name.GetData(), current_step, sequence[current_step]->GetName());
            interrupted = false;
        }

        return RunScript(npc,eventmgr,false);
    }
}
예제 #3
0
bool ScriptingTest::Run(int argc, char** argv) {
    mFailed = false;

    dt::Root::GetInstance().Initialize(argc, argv);

    dt::ScriptManager::Get()->AddScript("print(DT_VERSION);", "print_test");
    dt::ScriptManager::Get()->AddScript("DT_VERSION", "return_version");
    dt::ScriptManager::Get()->AddScript("print(TotalTime);", "update_context");
    dt::ScriptManager::Get()->LoadScript("scripts/test_load_script_file.js");

    RunScript("print_test");
    RunScript("return_version", dt::Root::_VERSION);
    RunScript("test_load_script_file.js", "test");

    sf::Sleep(sf::Milliseconds(100));
    dt::ScriptManager::Get()->UpdateContext();
    RunScript("update_context");

    if(mFailed) {
        std::cout << "Test Script: Errors occured." << std::endl;
        return false;
    }

    dt::Root::GetInstance().Deinitialize();
    return true;
}
예제 #4
0
void WSL::Framework::Standard::Positional::PositionalInitialize()
{
	if( initialize == true ) {
		RunScript( initializeScript );
		SetPosition( position );
	}
}
예제 #5
0
void JavaScriptEngine::Start() {

	globalRuntime = JS_NewRuntime(32L * 1024L * 1024L);
	if (globalRuntime == NULL) {
		LogInfo(TAG, "(globalRuntime == NULL)");
		return;
	}
	globalContext = JS_NewContext(globalRuntime, 8192);
	if (globalContext == NULL) {
		LogInfo(TAG, "(globalContext == NULL)");
		return;
	}
	JS_SetOptions(globalContext, JSOPTION_VAROBJFIX);
	JS_SetVersion(globalContext, JSVERSION_LATEST);
	JS_SetErrorReporter(globalContext, ReportError);
	globalObject = JS_NewCompartmentAndGlobalObject(globalContext,
			&globalClass, NULL);
	if (globalObject == NULL) {
		LogInfo(TAG, "(globalObject == NULL)");
		return;
	}
	if (!JS_InitStandardClasses(globalContext, globalObject)) {
		LogInfo(TAG, "(!JS_InitStandardClasses(globalContext, global))");
		return;
	}
	BindingGlobalObject();
	BindingObject();
	RunScript("index.js");
}
예제 #6
0
int main()
{
	Lua luaInstance;
	std::stringstream ss;
	auto globalTable = luaInstance.GetGlobalEnvironment();
	auto myOwnPrint = luaInstance.CreateYieldingFunction<void(std::string)>
		(
			[&](std::string str)
			{
				ss << str;
			}
		);

	globalTable.Set("myownprint", myOwnPrint);

	luaInstance.LoadStandardLibraries();

	auto cr = luaInstance.CreateCoroutine();

	auto err = cr.RunScript(
		"	myownprint 'hello '\n"
		"	myownprint 'hello2 '\n"
		"	myownprint 'hello3 '\n"
		);
	
	while (cr.CanResume())
	{
		ss << "yield ";
		auto err = cr.Resume();
	}
	
	auto resstr = ss.str();
	
	return resstr.compare("hello yield hello2 yield hello3 yield ");
}
void ScriptInterface::RunScript( QObject* obj, QString filename )
{
  QScriptContext* context = m_scriptEngine.pushContext( );
  context->setThisObject( m_scriptEngine.toScriptValue( obj ) );
  RunScript( filename );
  PopThis( );
}
예제 #8
0
void AHKHandler::GameStart()
{
	wstring app = (L"C://0adProcessor/Scripts/Start.exe");
	LPWSTR appName = (LPWSTR)app.c_str();

	RunScript(appName);
}
예제 #9
0
bool Behavior::ResumeScript(NPC *npc,EventManager *eventmgr)
{
    if (current_step < sequence.GetSize())
    {
        npc->Printf(3, "Resuming behavior %s at step %d - %s.",
                    name.GetData(),current_step,sequence[current_step]->GetName());

        if (sequence[current_step]->CompleteOperation(npc,eventmgr))
        {
            npc->Printf(2,"Completed step %d - %s of behavior %s",
                        current_step,sequence[current_step]->GetName(),name.GetData());
            current_step++;
            return RunScript(npc, eventmgr, false);
        }
        else
        {
            return false; // This behavior isn't done yet
        }

    }
    else
    {
        Error2("No script operation to resume for behavior '%s'",GetName());
        return true;
    }
}
예제 #10
0
int main(int argc, char* argv[])
{
  OMX_Init();

  if (argc == 2)
  {
    OMX_STRING pScriptFile = (OMX_STRING) argv[1];

    RunScript(pScriptFile);
  }
  else if (argc == 4)
  {
    OMX_STRING pTestName = (OMX_STRING) argv[1];
    OMX_STRING pConfigFile = (OMX_STRING) argv[2];
    OMX_STRING pNumSession = (OMX_STRING) argv[3];
    OMX_S32 nSession;

    nSession = atoi((char*) pNumSession);

    RunTest(pTestName, pConfigFile, nSession);
  }
  else
  {
    VENC_TEST_MSG_ERROR("invalid number of command args %d", argc);
    VENC_TEST_MSG_ERROR("./mm-venc-omx-test ENCODE Config.cfg 1");
  }

  OMX_Deinit();
}
예제 #11
0
void PythonSpellIntegration::SpellTrigger(int spellId, SpellEvent evt) {
	bool cancelled = 0;

	SpellPacketBody spellPktBody;
	spellSys.GetSpellPacketBody(spellId, &spellPktBody);
	if (evt == SpellEvent::SpellEffect && spellPktBody.targetListNumItems > 0) {
		for (uint32_t i = 0; i < spellPktBody.targetListNumItems; i++) {
			auto tgtObj = spellPktBody.targetListHandles[i];
			// TODO: Verify attachee vs. target here
			if (!pythonObjIntegration.ExecuteObjectScript(spellPktBody.objHndCaster, tgtObj, spellId, ObjScriptEvent::SpellCast)) {
				cancelled = 1;
			}
		}
		if (cancelled) {
			return;
		}
	}


	auto pySpell = PySpell_Create(spellId);
	auto args = Py_BuildValue("(O)", pySpell);

	auto spellEnum = spellSys.GetSpellEnumFromSpellId(spellId);
	auto result = RunScript(spellEnum, (EventId)evt, args);
	Py_DECREF(args);

	// Result of RunScript is a bit different here
	if (result == 0 || result == -1) {
		PySpell_UpdatePacket(pySpell);
		addresses.SpellSoundPlay(&spellPktBody, evt);
	}
	Py_DECREF(pySpell);
}
예제 #12
0
파일: luafunc.cpp 프로젝트: skopp/rush
int JLuaServer::FnRequire( lua_State* pLua )
{
    if (lua_gettop( pLua ) != 1)
    {
        rlog.err( "LUA: Incorrect command usage: <require>. "
            "Function takes 1 string argument, but %d is provided", lua_gettop( pLua ) );
        lua_settop( pLua, 0 );
        lua_pushnil( pLua );
        return 1;
    }
    if (!lua_isstring( pLua, -1 ))
    {
        rlog.err( "LUA: Incorrect command usage: <require>. "
            "Function expects 1 string argument, for example: require('myfile.lua')" );
        lua_settop( pLua, 0 );
        lua_pushnil( pLua );
        return 1;
    }
    const char* pScriptName = lua_tostring( pLua, -1 );

    Path path( pScriptName );
    int scriptID = GetScriptID( path.GetFile() );
    JLuaThread* pThread = reinterpret_cast<JLuaThread*>( pLua->userdata );
    assert( pThread->m_pLua == pLua );
    JObject* pRootObj = pThread->m_pRootObj;
    JString res;
    int threadID = RunScript( scriptID, pRootObj, &res );
    return 0;
} // JLuaServer::FnRequire
예제 #13
0
파일: bd.cpp 프로젝트: MartovKot/ZHSK
bool BD::Create()
{
    if (!RunScript("./update_db/baseline.sql")){
        qDebug() << "Error run " << "./update_db/baseline.sql";
        return false;
    }
    return true;
}
예제 #14
0
bool ScopeScript::MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command)
{
    char _rate[] = { (char)('0' + IUFindOnSwitchIndex(&SlewRateSP)), 0 };
    bool status =
        RunScript(command == MOTION_STOP ? SCRIPT_ABORT : dir == DIRECTION_WEST ? SCRIPT_MOVE_WEST : SCRIPT_MOVE_EAST,
                  _rate, nullptr, nullptr);
    return status;
}
예제 #15
0
void AHKHandler::StartAsHost()
{
	Launch0Ad();

	LPWSTR appName = (LPWSTR)L"C://0adProcessor/Scripts/Host.exe";

	RunScript(appName);
}
예제 #16
0
bool DomeScript::Abort()
{
    bool status = RunScript(SCRIPT_ABORT, nullptr);
    if (status)
    {
        LOG_INFO("Successfully aborted");
    }
    return status;
}
예제 #17
0
파일: bd.cpp 프로젝트: MartovKot/ZHSK
void BD::UpdateDataBase()
{
    QString str;
    QSqlQuery query;
    QString version;

    version = getDatabaseVersion();

    if (version == "1.5"){
        str = "UPDATE version SET version = '01.05.000' WHERE version = 1.5";
        if (!query.exec(str)) {
            qDebug()<<query.lastError();
            LogOut.logout(query.lastError().text());
        }
        UpdateDataBase();
        return;
    }

    QDir dir_with_sql("./update_db");
    QStringList filters;
    QStringList list_with_sql;
    QStringList list_update;
    filters << "??_??_???.sql";
    list_with_sql = dir_with_sql.entryList(filters,QDir::Files,QDir::Name);

    QString major;
    QString minor;
    QString subversion;

    major = version.left(2);
    minor = version.mid(3,2);
    subversion = version.right(3);

    for(int i = 0;i < list_with_sql.count();i++){
        if(list_with_sql.at(i).left(2).toInt() > major.toInt()){
            list_update << dir_with_sql.absoluteFilePath(list_with_sql.at(i));
        }else if(list_with_sql.at(i).left(2).toInt() == major.toInt()){
            if(list_with_sql.at(i).mid(3,2).toInt() > minor.toInt()){
                list_update << dir_with_sql.absoluteFilePath(list_with_sql.at(i));
            }else if (list_with_sql.at(i).mid(3,2).toInt() == minor.toInt()){
                if((list_with_sql.at(i).mid(6,3).toInt() > subversion.toInt())){
                    list_update << dir_with_sql.absoluteFilePath(list_with_sql.at(i));
                }
            }
        }
    }

    for (int i=0;i<list_update.count();i++){
        if (!RunScript(list_update.at(i))){
            qDebug() << "Error run " << list_update.at(i);
        }else{
            qDebug() << "run script" << list_update.at(i);
        }
    }
    QueryExecute("VACUUM");

}
예제 #18
0
IPState DomeScript::ControlShutter(ShutterOperation operation)
{
    if (RunScript(operation == SHUTTER_OPEN ? SCRIPT_OPEN : SCRIPT_CLOSE, nullptr))
    {
        return IPS_BUSY;
    }
    LOGF_ERROR("Failed to %s shutter", operation == SHUTTER_OPEN ? "open" : "close");
    return IPS_ALERT;
}
예제 #19
0
파일: main.cpp 프로젝트: ypyf/PolyScript
int main(int argc, char* argv[])
{
    if (argc < 2) {
        printf("%s: no input files\n", argv[0]);
        exit(0);
    }

    RunScript(argv[1]);
}
예제 #20
0
bool ScopeScript::UnPark()
{
    bool status = RunScript(SCRIPT_UNPARK, nullptr);
    if (!status)
    {
        LOG_ERROR("Failed to unpark");
    }
    return status;
}
예제 #21
0
bool ScopeScript::Disconnect()
{
    bool status = RunScript(SCRIPT_DISCONNECT, nullptr);
    if (status)
    {
        LOG_INFO("Successfully disconnected");
    }
    return status;
}
예제 #22
0
void WSL::Framework::Standard::Positional::PositionalRefresh()
{
	if( refresh == true )
	{
		RunScript( refreshScript );
		if( physicalBehavior != "NULL" )
			RunPhysScript( physicalBehavior );
		SetPosition( position );
	}
}
예제 #23
0
bool AutotestingSystemLua::RunScriptFromFile(const FilePath &luaFilePath)
{
    Logger::Debug("AutotestingSystemLua::RunScriptFromFile %s", luaFilePath.GetAbsolutePathname().c_str());
    if(LoadScriptFromFile(luaFilePath))
    {
		lua_pushstring(luaState, luaFilePath.GetBasename().c_str());
        return RunScript();
    }
    return false;
}
예제 #24
0
IPState DomeScript::UnPark()
{
    bool status = RunScript(SCRIPT_UNPARK, nullptr);
    if (status)
    {
        return IPS_BUSY;
    }
    LOG_ERROR("Failed to unpark");
    return IPS_ALERT;
}
예제 #25
0
/**
 * Initializes instance of GameSetup
 */
void SpringApp::Startup()
{
	// bash input
	const std::string inputFile = cmdline->GetInputFile();
	const std::string extension = FileSystem::GetExtension(inputFile);

	// note: avoid any .get() leaks between here and GameServer!
	clientSetup.reset(new ClientSetup());

	// create base client-setup
	if (cmdline->IsSet("server")) {
		clientSetup->hostIP = cmdline->GetString("server");
		clientSetup->isHost = true;
	}

	clientSetup->myPlayerName = configHandler->GetString("name");
	clientSetup->SanityCheck();

	// no argument (either game is given or show selectmenu)
	if (inputFile.empty()) {
		clientSetup->isHost = true;
		if (cmdline->IsSet("game") && cmdline->IsSet("map")) {
			// --game and --map directly specified, try to run them
			activeController = RunScript(StartScriptGen::CreateMinimalSetup(cmdline->GetString("game"), cmdline->GetString("map")));
			return;
		}
		LoadSpringMenu();
		return;
	}

	// process given argument
	if (inputFile.find("spring://") == 0) {
		// url (syntax: spring://username:password@host:port)
		if (!ParseSpringUri(inputFile, clientSetup->myPlayerName, clientSetup->myPasswd, clientSetup->hostIP, clientSetup->hostPort))
			throw content_error("invalid url specified: " + inputFile);

		clientSetup->isHost = false;
		pregame = new CPreGame(clientSetup);
	} else if (extension == "sdf") {
		// demo
		clientSetup->isHost        = true;
		clientSetup->myPlayerName += " (spec)";

		pregame = new CPreGame(clientSetup);
		pregame->LoadDemo(inputFile);
	} else if (extension == "ssf") {
		// savegame
		clientSetup->isHost = true;

		pregame = new CPreGame(clientSetup);
		pregame->LoadSavefile(inputFile);
	} else {
		StartScript(inputFile);
	}
}
예제 #26
0
G_MODULE_EXPORT void FbsetOk_released()												// Change fbset resolution
{
	int x, y;
	int FbX = gtk_adjustment_get_value(FBSETX);
	int FbY = gtk_adjustment_get_value(FBSETY);
	char RunString[28];
	sprintf(RunString, "scripts/Tweaks/fbset-set %d %d", FbX, FbY);
	RunScript(RunString);
	gtk_window_fullscreen(GTK_WINDOW(Window_QuickSetup));
	gtk_window_unfullscreen(GTK_WINDOW(Window_QuickSetup));
}
예제 #27
0
bool CHooks::StartUpdate(const CTGitPathList& pathList, DWORD& exitcode, CString& error)
{
	hookiterator it = FindItem(start_update_hook, pathList);
	if (it == end())
		return false;
	CString sCmd = it->second.commandline;
	AddPathParam(sCmd, pathList);
	AddCWDParam(sCmd, pathList);
	exitcode = RunScript(sCmd, pathList.GetCommonRoot().GetDirectory().GetWinPath(), error, it->second.bWait, it->second.bShow);
	return true;
}
예제 #28
0
bool CHooks::PostPush(const CString& workingTree, DWORD& exitcode, CString& error)
{
	auto it = FindItem(post_push_hook, workingTree);
	if (it == end())
		return false;
	CString sCmd = it->second.commandline;
	AddErrorParam(sCmd, error);
	AddCWDParam(sCmd, workingTree);
	exitcode = RunScript(sCmd, workingTree, error, it->second.bWait, it->second.bShow);
	return true;
}
예제 #29
0
void SpringApp::Reload(const std::string& script)
{
	// get rid of any running worker threads
	ThreadPool::SetThreadCount(0);
	ThreadPool::SetThreadCount(ThreadPool::GetMaxThreads());

	if (gameServer != NULL)
		gameServer->SetReloading(true);

	//Lua shutdown functions need to access 'game' but SafeDelete sets it to NULL.
	game->KillLua();

	SafeDelete(game);
	SafeDelete(pregame);

	// no-op if we are not the server
	SafeDelete(gameServer);
	// PreGame allocates clientNet, so we need to delete our old connection
	SafeDelete(clientNet);

	SafeDelete(battery);

	// note: technically we only need to use RemoveArchive
	FileSystemInitializer::Cleanup(false);
	FileSystemInitializer::Initialize();

	CNamedTextures::Kill();
	CNamedTextures::Init();

	LuaOpenGL::Free();
	LuaOpenGL::Init();

	// reload sounds.lua in case we switch to a different game
	ISound::Shutdown();
	ISound::Initialize();

	// make sure all old EventClients are really gone (safety)
	eventHandler.ResetState();

	battery = new CBattery();

	gu->ResetState();
	gs->ResetState();

	// must hold or we would loop forever
	assert(!gu->globalReload);

	if (script.empty()) {
		// if no script, drop back to menu
		LoadSpringMenu();
	} else {
		activeController = RunScript(script);
	}
}
예제 #30
0
bool ScopeScript::Sync(double ra, double dec)
{
    char _ra[16], _dec[16];
    snprintf(_ra, 16, "%f", ra);
    snprintf(_dec, 16, "%f", dec);
    bool status = RunScript(SCRIPT_SYNC, _ra, _dec, nullptr);
    if (status)
    {
        LOG_INFO("Sync succesfully executed");
    }
    return status;
}