コード例 #1
0
void LuaState::OpenLibs()
{
#if LUAPLUS_INCLUDE_STANDARD_LIBRARY
	LuaAutoBlock autoBlock(this);
	lua_cpcall(LuaState_to_lua_State(this), &pmain, NULL);
#endif // LUAPLUS_INCLUDE_STANDARD_LIBRARY
}
コード例 #2
0
ファイル: LuaPlus.cpp プロジェクト: brock7/TianLong
void LuaState::Init( bool initStandardLibrary )
{
	// Register some basic functions with Lua.
	if (initStandardLibrary)
	{
		// A "bug" in Lua 5.01 causes stack entries to be left behind.
		LuaAutoBlock autoBlock(this);
		luaopen_base(m_state);
		luaopen_table( m_state );
		luaopen_io(m_state);
		luaopen_string(m_state);
		luaopen_wstring(m_state);
		luaopen_math(m_state);
		luaopen_debug(m_state);
#ifndef _WIN32_WCE
		luaopen_loadlib(m_state);
#endif _WIN32_WCE

		ScriptFunctionsRegister( this );

		GetGlobals().Register("LuaDumpGlobals", LS_LuaDumpGlobals);
		GetGlobals().Register("LuaDumpObject", LS_LuaDumpObject);
		GetGlobals().Register("LuaDumpFile", LS_LuaDumpFile);
	}

	GetGlobals().Register("LOG", LS_LOG);
	GetGlobals().Register("_ALERT", LS_LOG);

	lua_atpanic( m_state, FatalError );
}
コード例 #3
0
void LuaState::Init( bool initStandardLibrary )
{
#if LUAPLUS_INCLUDE_STANDARD_LIBRARY
	// Register some basic functions with Lua.
	if (initStandardLibrary)
	{
		LuaAutoBlock autoBlock(this);

		lua_cpcall(m_state, &pmain, NULL);

#ifdef LUA_MTSUPPORT
//        luaopen_thread(m_state);
#endif // LUA_MTSUPPORT

		ScriptFunctionsRegister( this );

        GetGlobals().Register("LuaDumpGlobals", LS_LuaDumpGlobals);
		GetGlobals().Register("LuaDumpObject", LS_LuaDumpObject);
		GetGlobals().Register("LuaDumpFile", LS_LuaDumpFile);

		GetGlobals().Register("LOG", LS_LOG);
		GetGlobals().Register("_ALERT", LS_ALERT);
	}
#endif // LUAPLUS_INCLUDE_STANDARD_LIBRARY

	lua_atpanic( m_state, FatalError );
}
コード例 #4
0
//--------------------------------------------------------------------
// @mfunc Tokenize the Data values and retursn the column record
//
// @rdesc HRESULT
//      @flag S_OK | Parsing yielded no Error
//      @flag E_FAIL | Data value could not be parsed or stored
//
HRESULT CParseInitFile::GetData(DBCOUNTITEM ulRow,DBORDINAL ulColumn, WCHAR* pwszData, DBTYPE *pwType)
{
	ASSERT(pwszData);

	//NOTE: Since we are moving the file pointer here, we need to block so that
	//our data access to the low level file is atomic.  Otherwise threading variations
	//comparing data will get bogus data since the starting location is not correct...
	CAutoBlock autoBlock(m_csFile.GetCS());

	DBLENGTH dwLength = 0;
	CHAR* pszOffset = NULL;
	HRESULT hr = S_OK;

	TRACE_CALL(L"PRIVLIB: CParseInitFile::GetData.\n");

	if(FAILED(hr = FetchRow(ulRow)))
		goto CLEANUP;

	if(FAILED(hr = ParseRowValues(ulColumn, &pszOffset, &dwLength, pwType)))
		goto CLEANUP;

	//Check for (null) data
	if(hr == S_FALSE)
		return hr; //Indicate NULL

	if(dwLength > MAXDATALEN)
		dwLength = MAXDATALEN;

	if(dwLength)
	{
		//Convert to WCHAR.
		//NOTE: ParseRowValues returns the actual number of bytes obtained.  We need to 
		//know the actual number of characters which may be different for MBCS
		dwLength = MultiByteToWideChar(CP_ACP, 0, pszOffset, (INT)dwLength, pwszData, MAXDATALEN);
		if(!dwLength)
			TESTC_(hr = E_FAIL, S_OK);
	}

	//Add NULL terminator
	pwszData[dwLength] = L'\0';

CLEANUP:
	return hr;
}
コード例 #5
0
ファイル: LuaPlus_Libs.cpp プロジェクト: korman/Temp
void LuaState::OpenLibs()
{
#if LUAPLUS_INCLUDE_STANDARD_LIBRARY
	LuaAutoBlock autoBlock(this);
	lua_cpcall(m_state, &pmain, NULL);

#ifdef LUA_MTSUPPORT
//        luaopen_thread(m_state);
#endif // LUA_MTSUPPORT

	ScriptFunctionsRegister(this);

    GetGlobals().Register("LuaDumpGlobals", LS_LuaDumpGlobals);
	GetGlobals().Register("LuaDumpObject", LS_LuaDumpObject);
	GetGlobals().Register("LuaDumpFile", LS_LuaDumpFile);

	GetGlobals().Register("LOG", LS_LOG);
	GetGlobals().Register("_ALERT", LS_ALERT);
#endif // LUAPLUS_INCLUDE_STANDARD_LIBRARY
}
コード例 #6
0
ファイル: Debrief.cpp プロジェクト: MrPhil/ShortHike
void
Debrief::show()
{
  lua_State* cLuaState = rMain()->getMission()->getLuaState()->GetCState();
  LuaAutoBlock autoBlock(cLuaState);
  lua_getglobal(cLuaState, "trigger_get_bonus_summary");
  if(lua_pcall(cLuaState, 0, 2, 0)) {
    logGameInfo(string("Lua: ") + lua_tostring(cLuaState, -1));
    mDebriefing->setLabel(L"No debrief provided");
  }
  else {
    if(!lua_isstring(cLuaState, -2)) return;
    if(!lua_isnumber(cLuaState, -1)) return;
    float bonusAmount = lua_tonumber(cLuaState, -1);
    wostringstream wossDebriefMessage;
    wossDebriefMessage << L"Station manager bonus breakdown:" << endl
                       << stringToWString(lua_tostring(cLuaState, -2)) << endl
                       << endl;
    if(bonusAmount < 1.5)
      wossDebriefMessage << L"Total: $" << bonusAmount * 1000 << "k";
    else
      wossDebriefMessage << L"Total: $" << bonusAmount << "M";
    mDebriefing->setLabel(wossDebriefMessage.str());
    ConfigManager::getHomeBase()->creditTransaction(bonusAmount);

    Player* player = ConfigManager::getPlayer();
    player->mExperience += bonusAmount;
    if(player->mLargestBonus < bonusAmount) {
      player->mLargestBonus = bonusAmount;
      player->mLargestBonusMission = rMain()->getMission()->getName();
    }      

    ConfigManager::getSingleton().savePlayer();
  }  

  Dialog::show();
}