当前位置: 首页>>代码示例>>C++>>正文


C++ Lua_ValueToNumber函数代码示例

本文整理汇总了C++中Lua_ValueToNumber函数的典型用法代码示例。如果您正苦于以下问题:C++ Lua_ValueToNumber函数的具体用法?C++ Lua_ValueToNumber怎么用?C++ Lua_ValueToNumber使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Lua_ValueToNumber函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LuaRenameConflictTong

int LuaRenameConflictTong(Lua_State* L)
{
    BOOL        bRetCode        = false;
    int         nTopIndex       = 0;
    int         nConnIndex      = 0;
    DWORD       dwPlayerID      = ERROR_ID;
    DWORD       dwTongID        = ERROR_ID;
    const char* pszNewName      = NULL;
    size_t      uNewNameLen     = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 4);

    nConnIndex = (int)Lua_ValueToNumber(L, 1);
    KGLOG_PROCESS_ERROR(nConnIndex);

    dwPlayerID = (DWORD)Lua_ValueToNumber(L, 2);
    KGLOG_PROCESS_ERROR(dwPlayerID != ERROR_ID);

    dwTongID = (DWORD)Lua_ValueToNumber(L, 3);
    KGLOG_PROCESS_ERROR(dwTongID != ERROR_ID);

    pszNewName = (const char*)Lua_ValueToString(L, 4);
    KGLOG_PROCESS_ERROR(pszNewName);

    uNewNameLen = strlen(pszNewName);
    KGLOG_PROCESS_ERROR(uNewNameLen < _NAME_LEN);

    g_pSO3GameCenter->m_TongManager.ProcessRenameConflictTong(nConnIndex, dwPlayerID, dwTongID, pszNewName);

Exit0:
    return 0;
}
开发者ID:viticm,项目名称:pap2,代码行数:33,代码来源:KScriptFuncList.cpp

示例2: LuaSendPrizeInfo

int LuaSendPrizeInfo(Lua_State* L)
{
    int         nRetCode        = 0;
    int         nTopIndex       = 0;
    DWORD       dwPlayerID      = ERROR_ID;
    KRole*      pRole           = NULL;
    const char* pszType         = NULL;
    int         nValue          = 0;

    nTopIndex =  Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);

    dwPlayerID = (DWORD)Lua_ValueToNumber(L, 1);
    KGLOG_PROCESS_ERROR(dwPlayerID);

    pszType = (const char*)Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pszType);

    nValue = (int)Lua_ValueToNumber(L, 3);

    assert(g_pSO3GameCenter);
    pRole = g_pSO3GameCenter->m_RoleManager.GetRole(dwPlayerID);
    KGLOG_PROCESS_ERROR(pRole);

    g_pSO3GameCenter->m_Eyes.DoSendPrizeInfo(pRole->m_pszAccount, pRole->m_szName, dwPlayerID, pszType, nValue);   
Exit0:
    return 0;
}
开发者ID:viticm,项目名称:pap2,代码行数:28,代码来源:KScriptFuncList.cpp

示例3: Lua_GetTopIndex

int KHero::LuaCheckAISelfDefData(Lua_State* L)
{
    int nRetCode = KAI_BRANCH_ERROR;
    BOOL bRetCode	= false;
    int	 nTopIndex	= 0;
    const char* pszKey = NULL;
    int nMinValue = 0;
    int nMaxValue = 0;
    int nCurValue = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);

    pszKey = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszKey);

    nMinValue = (int)Lua_ValueToNumber(L, 1);
    nMaxValue = (int)Lua_ValueToNumber(L, 2);

    if (m_dictAISelfDefData.find(pszKey) == m_dictAISelfDefData.end())
        goto Exit0;

    nCurValue = m_dictAISelfDefData[pszKey];
    if (nCurValue < nMinValue || nCurValue > nMaxValue)
    {
        nRetCode = KAI_BRANCH_FAILED;
        goto Exit0;
    }

    nRetCode = KAI_BRANCH_SUCCESS;
Exit0:
    Lua_PushNumber(L, nRetCode);
    return 1;
}
开发者ID:zhengguo85938406,项目名称:GameWorld,代码行数:34,代码来源:KLuaHero.cpp

示例4: Lua_GetTopIndex

int KTeamClient::LuaChangeMemberGroup(Lua_State* L)
{
    int      nTopIndex      = 0;
    DWORD    dwMemberID     = ERROR_ID;
    DWORD    dwDstMemberID  = ERROR_ID;
    int      nDstGroup      = -1;
    KPlayer* pPlayer        = NULL;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 2 || nTopIndex == 3);

    dwMemberID = (DWORD)Lua_ValueToNumber(L, 1);
    nDstGroup  = (int)Lua_ValueToNumber(L, 2);

    if (nTopIndex == 3)
    {
        dwDstMemberID = (DWORD)Lua_ValueToNumber(L, 3);
    }

    pPlayer = g_pSO3World->m_PlayerSet.GetObj(g_pSO3World->m_dwClientPlayerID);
    KGLOG_PROCESS_ERROR(pPlayer);

    KGLOG_PROCESS_ERROR(nDstGroup >= 0 && nDstGroup < m_nGroupNum);
    KGLOG_PROCESS_ERROR(pPlayer->m_dwID == m_dwAuthority[tatLeader]);

    g_PlayerClient.DoTeamChangeMemberGroupRequest(dwMemberID, nDstGroup, dwDstMemberID);

Exit0:
    return 0;
}
开发者ID:viticm,项目名称:pap2,代码行数:30,代码来源:KTeamClient.cpp

示例5: Lua_GetTopIndex

int KScene::LuaSetTimer(Lua_State* L)
{
    int         nParamCount     = 0;
    DWORD       dwID            = 0;
    int         nTime           = 0;
    const char* pszScriptName   = NULL;
    int         nParam1         = 0;
    int         nParam2         = 0;

    nParamCount = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nParamCount == 4);

    nTime           =   (int)Lua_ValueToNumber(L, 1);
    pszScriptName   =   Lua_ValueToString(L, 2);
    nParam1         =   (int)Lua_ValueToNumber(L, 3);
    nParam2         =   (int)Lua_ValueToNumber(L, 4);

    KGLOG_PROCESS_ERROR(pszScriptName);

    dwID = m_ScriptTimerList.SetTimer(nTime, pszScriptName, nParam1, nParam2);
    KGLOG_PROCESS_ERROR(dwID);

Exit0:
    lua_pushinteger(L, dwID);
    return 1;
}
开发者ID:zhengguo85938406,项目名称:GameWorld,代码行数:26,代码来源:KLuaScene.cpp

示例6: LuaGetSceneConnIndex

int LuaGetSceneConnIndex(Lua_State* L)
{
    int         nResult         = 0;
    int         nTopIndex       = 0;
    DWORD       dwMapID         = 0;
    int         nMapCopyIndex   = 0;
    KMapCopy*   pMapCopy        = NULL;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 2);

    dwMapID         = (DWORD)Lua_ValueToNumber(L, 1);
    nMapCopyIndex   = (int)Lua_ValueToNumber(L, 2);

    pMapCopy = g_pSO3GameCenter->m_MapManager.GetMapCopy(dwMapID, nMapCopyIndex);
    KG_PROCESS_ERROR(pMapCopy);
    
    nResult = pMapCopy->m_nConnIndex;
Exit0:
    if (nResult)
        Lua_PushNumber(L, nResult);
    else
        Lua_PushNil(L);

    return 1;
}
开发者ID:viticm,项目名称:pap2,代码行数:26,代码来源:KScriptFuncList.cpp

示例7: LuaCreateTong

int LuaCreateTong(Lua_State* L)
{
    int         nResult     = 0;
    BOOL        bRetCode    = false;
    int         nTopIndex   = 0;
    DWORD       dwPlayerID  = 0;
    const char* pszTongName = 0;
    int         nTemplateID = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);

    dwPlayerID  = (DWORD)Lua_ValueToNumber(L, 1);

    pszTongName = Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pszTongName);

    nTemplateID = (int)Lua_ValueToNumber(L, 3);

    bRetCode = g_pSO3GameCenter->m_TongManager.CreateTong(dwPlayerID, pszTongName, nTemplateID);
    
    Lua_PushBoolean(L, bRetCode);
    nResult = 1;
Exit0:
    return nResult;
}
开发者ID:viticm,项目名称:pap2,代码行数:26,代码来源:KScriptFuncList.cpp

示例8: LuaGetPlayerEnterNewCopyTimesInfo

int LuaGetPlayerEnterNewCopyTimesInfo(Lua_State* L)
{
    int         nResult             = 0;
    KMapInfo*   pMapInfo            = NULL;
    int         nTopIndex           = 0;
    DWORD       dwMapID             = 0;
    DWORD       dwPlayerID          = 0;
    int         nAlreadyEnterTimes  = 0;
    KNEW_MAP_LIMIT_TABLE::iterator it;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 2);
    
    dwMapID     = (DWORD)Lua_ValueToNumber(L, 1);
    dwPlayerID  = (DWORD)Lua_ValueToNumber(L, 2);

    pMapInfo = g_pSO3GameCenter->m_MapManager.GetMapInfo(dwMapID);
    KGLOG_PROCESS_ERROR(pMapInfo);
    
    KG_PROCESS_ERROR(pMapInfo->m_nType == emtDungeon || pMapInfo->m_nType == emtBattleField);

    it = pMapInfo->m_PlayerEnterNewCopyTimes.find(dwPlayerID);
    if (it != pMapInfo->m_PlayerEnterNewCopyTimes.end())
    {
        nAlreadyEnterTimes = it->second.nTimes;
    }   
    
    Lua_PushNumber(L, nAlreadyEnterTimes);

    nResult = 1;
Exit0:
    return nResult;
}
开发者ID:viticm,项目名称:pap2,代码行数:33,代码来源:KScriptFuncList.cpp

示例9: LuaRefreshMapCopy

int LuaRefreshMapCopy(Lua_State* L)
{
    BOOL        bResult         = false;
    BOOL        bRetCode        = false;
    int         nTopIndex       = 0;
    DWORD       dwMapID         = 0;
    int         nMapCopyIndex   = 0;
    KMapCopy*   pMapCopy        = NULL;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 2);

    dwMapID       = (DWORD)Lua_ValueToNumber(L, 1);
    nMapCopyIndex = (int)Lua_ValueToNumber(L, 2);

    pMapCopy = g_pSO3GameCenter->m_MapManager.GetMapCopy(dwMapID, nMapCopyIndex);
    KGLOG_PROCESS_ERROR(pMapCopy);
    KGLOG_PROCESS_ERROR(pMapCopy->m_nConnIndex);

    bRetCode = g_pSO3GameCenter->m_GameServer.DoMapCopyDoClearPlayerPrepare(
        pMapCopy->m_nConnIndex, dwMapID, nMapCopyIndex, bpcMapRefresh, BANISH_PLAYER_WAIT_SECONDS
    );
    KGLOG_PROCESS_ERROR(bRetCode);

    pMapCopy->m_eState       = eMapStateRefreshing;
    pMapCopy->m_nRefreshTime = g_pSO3GameCenter->m_nTimeNow + BANISH_PLAYER_WAIT_SECONDS;

Exit0:
    Lua_PushBoolean(L, bResult);
    return 1;
}
开发者ID:viticm,项目名称:pap2,代码行数:31,代码来源:KScriptFuncList.cpp

示例10: LuaRandom

int LuaRandom(Lua_State* L)
{
    int nResult = 0;
    int nRetCode = 0;
    int nX = 0;
    int nY = 0;

    nRetCode = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nRetCode == 1 || nRetCode == 2);

    if (nRetCode == 1)
    {
        nX = 1;
        nY = (int)Lua_ValueToNumber(L, 1);
    }
    else if (nRetCode == 2)
    {
        nX = (int)Lua_ValueToNumber(L, 1);
        nY = (int)Lua_ValueToNumber(L, 2);
    }
    else
    {
        KGLOG_PROCESS_ERROR(false);
    }

    KGLOG_PROCESS_ERROR(nX >= 1 && nY >= nX);

    nResult = g_Random(nY - nX + 1) + nX;
Exit0:
    lua_pushinteger(L, nResult);
    return 1;
}
开发者ID:viticm,项目名称:pap2,代码行数:32,代码来源:KScriptFuncList.cpp

示例11: LuaCreatePQ

int LuaCreatePQ(Lua_State* L)
{
    int     nResult         = 0;
    int     nTopIndex       = 0;
    DWORD   dwPQTemplateID  = 0;
    int     nOwnerType      = pqotInvalid;
    DWORD   dwOwnerID1      = 0;
    DWORD   dwOwnerID2      = 0;
    DWORD   dwOwnerID3      = 0;
    DWORD   dwPQID          = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 1 || nTopIndex == 5);

    dwPQTemplateID = (DWORD)Lua_ValueToNumber(L, 1);

    if (nTopIndex == 5)
    {
        nOwnerType = (int)Lua_ValueToNumber(L, 2);
        dwOwnerID1 = (DWORD)Lua_ValueToNumber(L, 3);
        dwOwnerID2 = (DWORD)Lua_ValueToNumber(L, 4);
        dwOwnerID3 = (DWORD)Lua_ValueToNumber(L, 5);
    }

    dwPQID = g_pSO3GameCenter->m_PQCenter.CreatePQ(dwPQTemplateID, (KGPQ_OWNER_TYPE)nOwnerType, dwOwnerID1, dwOwnerID2, dwOwnerID3);

Exit0:
    Lua_PushNumber(L, dwPQID);
    return 1;
}
开发者ID:viticm,项目名称:pap2,代码行数:30,代码来源:KScriptFuncList.cpp

示例12: Lua_GetTopIndex

int KAILogic::LuaNewAction(Lua_State* L)
{
    int         nResult     = 0;
    int         nRetCode    = 0;
    int         nActionID   = KAI_ACTION_ID_NONE;
    int         nActionKey  = eakInvalid;
    KAIAction*  pActionData = NULL;
    std::pair<KAI_ACTION_TABLE::iterator, bool> RetPair;

    nRetCode = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nRetCode == 2);

    nActionID = (int)Lua_ValueToNumber(L, 1);
    KGLOG_PROCESS_ERROR(nActionID > KAI_ACTION_ID_NONE);

    nActionKey = (int)Lua_ValueToNumber(L, 2);
    KGLOG_PROCESS_ERROR(nActionKey > eakInvalid);

    if (nActionKey < KAI_USER_ACTION)
    {
        KAI_ACTION_FUNC PAction  = NULL;

        PAction = g_pSO3World->m_AIManager.GetActionFunction(nActionKey);
        if (PAction == NULL)
        {
            KGLogPrintf(KGLOG_ERR, "[AI] Unregistered sys action(ID: %d, Key: %d) in ai %d\n", nActionID, nActionKey, m_nAIType);
            goto Exit0;
        }
    }
    else
    {
        KUSER_ACTION_TABLE::iterator it = m_UserActionTable.find(nActionKey);

        if (it == m_UserActionTable.end())
        {
            KGLogPrintf(KGLOG_ERR, "[AI] Unregistered lua actionID: %d, Key: %d) in ai %d\n", nActionID, nActionKey, m_nAIType);
            goto Exit0;
        }
    }

    RetPair = m_ActionTable.insert(std::make_pair(nActionID, KAIAction()));
    if (!RetPair.second)
    {
        KGLogPrintf(KGLOG_ERR, "[AI] Duplicated AI action(%d) in ai %d\n", nActionID, m_nAIType);
        goto Exit0;
    }

    pActionData = &(RetPair.first->second);

    pActionData->m_nKey = nActionKey;

    nResult = pActionData->LuaGetObj(L);
Exit0:
    return nResult;
}
开发者ID:zhengguo85938406,项目名称:GameWorld,代码行数:55,代码来源:KAILogic.cpp

示例13: LuaSetStatData

int LuaSetStatData(Lua_State* L)
{
    int         nTopIndex    = 0;
    int         nValue       = 0;
    size_t      uNameLen     = 0;
    const char* pszName      = NULL;
    const char* pszLuaPrefix = "lua_";
    char        szName[STAT_DATA_NAME_LEN];

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 2);

    pszName = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszName);

    uNameLen = strlen(pszName) + strlen(pszLuaPrefix) + 1;
    KGLOG_PROCESS_ERROR(uNameLen <= sizeof(szName));

    nValue = (int)Lua_ValueToNumber(L, 2);

    snprintf(szName, sizeof(szName), "%s%s", pszLuaPrefix, pszName);
    szName[sizeof(szName) - 1] = '\0';

    g_pSO3GameCenter->m_StatDataManager.SetDataValue(szName, nValue);

Exit0:
    return 0;
}
开发者ID:viticm,项目名称:pap2,代码行数:28,代码来源:KScriptFuncList.cpp

示例14: Lua_GetTopIndex

int KSchemeScriptTable::LuaInteraction_Request(Lua_State *L)
{
    int nRetCode = false;
    const char * pcszName = NULL;
    const char * pcszAddress = NULL;
    const char * pcszObjectName = NULL;
    const char * pcszVerb = NULL;
    int nPort = 0;
    int nParamCount = Lua_GetTopIndex(L);

    KGLOG_PROCESS_ERROR(nParamCount == 5);

    pcszName = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pcszName);

    pcszAddress = Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pcszAddress);

    pcszObjectName = Lua_ValueToString(L, 3);
    KGLOG_PROCESS_ERROR(pcszObjectName);

    pcszVerb = Lua_ValueToString(L, 4);
    KGLOG_PROCESS_ERROR(pcszVerb);

    nPort = (int)Lua_ValueToNumber(L, 5);

    nRetCode = g_pSO3UI->m_pInteraction->Request(pcszName, pcszAddress, pcszObjectName, pcszVerb, nPort, &Interaction_RequestResult);
    KGLOG_PROCESS_ERROR(nRetCode);

    lua_pushboolean(L, TRUE);
    return 1;
Exit0:
    lua_pushboolean(L, FALSE);
    return 1;
}
开发者ID:viticm,项目名称:pap2,代码行数:35,代码来源:kschemescripttable.cpp

示例15: LuaFreezeRole

int LuaFreezeRole(Lua_State* L)
{
    int         nRetCode        = false;
    const char* pszRoleName     = NULL;
    int         nFreezeSecond   = 0;
    time_t      nFreezeEndTime  = 0;
    KRole*      pRole           = NULL;

    nRetCode = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nRetCode == 2);

    pszRoleName = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszRoleName);

    nFreezeSecond = (int)Lua_ValueToNumber(L, 2);

    nFreezeEndTime = g_pSO3GameCenter->m_nTimeNow + nFreezeSecond;

    pRole = g_pSO3GameCenter->m_RoleManager.GetRole(pszRoleName);
    KGLOG_PROCESS_ERROR(pRole);

    nRetCode = g_pSO3GameCenter->m_RoleManager.FreezeRole(pRole->m_dwPlayerID, nFreezeEndTime);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = g_pSO3GameCenter->m_MiscDB.DoUpdateRoleBlackList(pRole->m_dwPlayerID, nFreezeEndTime);
    KGLOG_PROCESS_ERROR(nRetCode);

Exit0:
    return 0;
}
开发者ID:viticm,项目名称:pap2,代码行数:30,代码来源:KScriptFuncList.cpp


注:本文中的Lua_ValueToNumber函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。