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


C++ CScriptArgReader::ReadUserData方法代码示例

本文整理汇总了C++中CScriptArgReader::ReadUserData方法的典型用法代码示例。如果您正苦于以下问题:C++ CScriptArgReader::ReadUserData方法的具体用法?C++ CScriptArgReader::ReadUserData怎么用?C++ CScriptArgReader::ReadUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CScriptArgReader的用法示例。


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

示例1: argStream

int CLuaVector4Defs::Eq ( lua_State* luaVM )
{
    CLuaVector4D* pVector1 = NULL;
    CLuaVector4D* pVector2 = NULL;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pVector1 );
    argStream.ReadUserData ( pVector2 );

    if ( !argStream.HasErrors () )
    {
        lua_pushboolean ( luaVM, pVector1 == pVector2 );
        return 1;
    }
    else
    {
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
    }

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:StarSoftwareBuilder,项目名称:mtasa-blue,代码行数:22,代码来源:CLuaVector4Defs.cpp

示例2: InjectBrowserMouseWheel

int CLuaFunctionDefs::InjectBrowserMouseWheel ( lua_State* luaVM )
{
//  bool injectMouseWheel ( browser webBrowser, int scrollVertical, int scrollHorizontal )
    CClientWebBrowser* pWebBrowser; int iScrollVert; int iScrollHorz;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pWebBrowser );
    argStream.ReadNumber ( iScrollVert );
    argStream.ReadNumber ( iScrollHorz );

    if ( !argStream.HasErrors() )
    {
        pWebBrowser->InjectMouseWheel ( iScrollVert, iScrollHorz );
        lua_pushboolean ( luaVM, true );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Disinterpreter,项目名称:mtasa-blue,代码行数:22,代码来源:CLuaFunctionDefs.Browser.cpp

示例3: fileRead

int CLuaFileDefs::fileRead ( lua_State* luaVM )
{
//  string fileRead ( file theFile, int count )
    CScriptFile* pFile; unsigned long ulCount = 0;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pFile );
    argStream.ReadNumber ( ulCount );

    if ( !argStream.HasErrors () )
    {
        // Reading zero bytes from a file results in an empty string
        if ( ulCount == 0 )
        {
            lua_pushstring ( luaVM, "" );
            return 1;
        }

        // Allocate a buffer to read the stuff into and read some :~ into it
        CBuffer buffer;

        long lBytesRead = pFile->Read ( ulCount, buffer );
        if ( lBytesRead != -1 )
        {
            // Push the string onto the Lua stack. Use pushlstring so we are binary
            // compatible. Normal push string takes zero terminated strings.
            lua_pushlstring ( luaVM, buffer.GetData(), lBytesRead );
            return 1;
        }

        m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 );        
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
    
    // Error
    lua_pushnil ( luaVM );
    return 1;
}
开发者ID:Jusonex,项目名称:mtasa-blue,代码行数:39,代码来源:CLuaFileDefs.cpp

示例4: ExecuteCommandHandler

int CLuaFunctionDefs::ExecuteCommandHandler ( lua_State* luaVM )
{
    //  bool executeCommandHandler ( string commandName, player thePlayer, [ string args ] )
    SString strKey; CElement* pElement; SString strArgs;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadString ( strKey );
    argStream.ReadUserData ( pElement );
    argStream.ReadString ( strArgs, "" );

    if ( !argStream.HasErrors () )
    {

        // Grab our VM
        CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
        if ( pLuaMain )
        {
            CClient* pClient = NULL;
            if ( pElement->GetType () == CElement::PLAYER )
                pClient = static_cast <CClient*> ( static_cast <CPlayer*> ( pElement ) );

            if ( pClient )
            {

                // Call it
                if ( m_pRegisteredCommands->ProcessCommand ( strKey, strArgs, pClient ) )
                {
                    lua_pushboolean ( luaVM, true );
                    return 1;
                }
            }
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Jusonex,项目名称:mtasa-blue,代码行数:39,代码来源:CLuaFunctionDefs.Server.cpp

示例5: GetPlayerPing

int CLuaPlayerDefs::GetPlayerPing ( lua_State* luaVM )
{
    //  int getPlayerPing ( player thePlayer )
    CClientPlayer* pPlayer;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pPlayer );

    if ( !argStream.HasErrors () )
    {
        // Grab his ping
        unsigned int uiPing = pPlayer->GetPing ();
        lua_pushnumber ( luaVM, uiPing );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    // Failed
    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Anubhav652,项目名称:mtasa-blue,代码行数:22,代码来源:CLuaPlayerDefs.cpp

示例6: GetResourceRootElement

int CLuaResourceDefs::GetResourceRootElement ( lua_State* luaVM )
{
    // Verify arguments
    CResource* pResource = NULL;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pResource, NULL );

    // No resource given, get this resource's root
    if ( !argStream.HasErrors () )
    {
        if ( !pResource )
        {
            // Find our vm and get the root
            CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
            if ( pLuaMain )
            {
                pResource = pLuaMain->GetResource ();
            }
        }

        // Did we find a resource?
        if ( pResource )
        {
            // Grab the root element of it and return it if it existed
            CClientEntity* pEntity = pResource->GetResourceEntity ();
            if ( pEntity )
            {
                lua_pushelement ( luaVM, pEntity );
                return 1;
            }
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    // Failed
    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Jusonex,项目名称:mtasa-blue,代码行数:39,代码来源:CLuaResourceDefs.cpp

示例7: SetWeaponClipAmmo

int CLuaFunctionDefs::SetWeaponClipAmmo ( lua_State* luaVM )
{
    CClientWeapon * pWeapon = NULL;
    int iAmmo = 0;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pWeapon );
    argStream.ReadNumber ( iAmmo );

    if ( !argStream.HasErrors() )
    {
        if ( CStaticFunctionDefinitions::SetWeaponClipAmmo( pWeapon, iAmmo ) )
        {
            lua_pushboolean ( luaVM, true );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:22,代码来源:CLuaFunctionDefs.Weapon.cpp

示例8: SetWeaponState

int CLuaFunctionDefs::SetWeaponState ( lua_State* luaVM )
{
    CClientWeapon * pWeapon;
    eWeaponState weaponState;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pWeapon );
    argStream.ReadEnumString ( weaponState );

    if ( !argStream.HasErrors () )
    {
        if ( CStaticFunctionDefinitions::SetWeaponState ( pWeapon, weaponState ) )
        {
            lua_pushboolean ( luaVM, true );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:22,代码来源:CLuaFunctionDefs.Weapon.cpp

示例9: MixedReadMaterialString

//
// Material/string
//
void MixedReadMaterialString(CScriptArgReader& argStream, CClientMaterial*& pMaterialElement)
{
    pMaterialElement = NULL;
    if (!argStream.NextIsString())
        argStream.ReadUserData(pMaterialElement);
    else
    {
        SString strFilePath;
        argStream.ReadString(strFilePath);

        // If no element, auto find/create one
        CLuaMain*  pLuaMain = g_pClientGame->GetLuaManager()->GetVirtualMachine(argStream.m_luaVM);
        CResource* pParentResource = pLuaMain ? pLuaMain->GetResource() : NULL;
        if (pParentResource)
        {
            CResource* pFileResource = pParentResource;
            SString    strPath, strMetaPath;
            if (CResourceManager::ParseResourcePathInput(strFilePath, pFileResource, &strPath, &strMetaPath))
            {
                SString strUniqueName = SString("%s*%s*%s", pParentResource->GetName(), pFileResource->GetName(), strMetaPath.c_str()).Replace("\\", "/");
                pMaterialElement = g_pClientGame->GetManager()->GetRenderElementManager()->FindAutoTexture(strPath, strUniqueName);

                if (pMaterialElement)
                {
                    // Check if brand new
                    if (!pMaterialElement->GetParent())
                        // Make it a child of the resource's file root ** CHECK  Should parent be pFileResource, and element added to pParentResource's
                        // ElementGroup? **
                        pMaterialElement->SetParent(pParentResource->GetResourceDynamicEntity());
                }
                else
                    argStream.SetCustomError(strFilePath, "Error loading image");
            }
            else
                argStream.SetCustomError(strFilePath, "Bad file path");
        }
    }
}
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:41,代码来源:CLuaFunctionParseHelpers.cpp

示例10: DxGetTextWidth

int CLuaOOPDefs::DxGetTextWidth ( lua_State* luaVM )
{
    //  float dxGetTextWidth ( string text, [float scale=1, mixed font="default", bool colorCoded=false] )
    SString strText; float fScale; CClientDxFont* pDxFontElement; bool bColorCoded;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pDxFontElement );
    argStream.ReadString ( strText );
    argStream.ReadNumber ( fScale, 1 );
    argStream.ReadBool ( bColorCoded, false );

    if ( !argStream.HasErrors () )
    {
        ID3DXFont* pD3DXFont = CStaticFunctionDefinitions::ResolveD3DXFont ( FONT_DEFAULT, pDxFontElement );

        // Retrieve the longest line's extent
        std::stringstream ssText ( strText );
        std::string sLineText;
        float fWidth = 0.0f, fLineExtent = 0.0f;

        while ( std::getline ( ssText, sLineText ) )
        {
            fLineExtent = g_pCore->GetGraphics ()->GetDXTextExtent ( sLineText.c_str (), fScale, pD3DXFont, bColorCoded );
            if ( fLineExtent > fWidth )
                fWidth = fLineExtent;
        }

        // Success
        lua_pushnumber ( luaVM, fWidth );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    // Failed
    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:38,代码来源:CLuaOOPFunctionDefs.Drawing.cpp

示例11: fileSetPos

int CLuaFileDefs::fileSetPos ( lua_State* luaVM )
{
    // bool fileSetPos ( file )

    // Grab the file pointer
    CScriptFile* pFile = NULL;
    unsigned long ulPosition = 0;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pFile );
    argStream.ReadNumber ( ulPosition );

    if ( !argStream.HasErrors ( ) )
    {
        if ( pFile )
        {
            long lResultPosition = pFile->SetPointer ( ulPosition );
            if ( lResultPosition != -1 )
            {
                // Set the position and return where we actually got it put
                lua_pushnumber ( luaVM, lResultPosition );
            }
            else
            {
                m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 );
                lua_pushnil ( luaVM );
            }
            return 1;
        }
        else
            m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 );
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    // Error
    lua_pushnil ( luaVM );
    return 1;
}
开发者ID:F420,项目名称:mtasa-blue,代码行数:38,代码来源:CLuaFileDefs.cpp

示例12: SetBanNick

int CLuaBanDefs::SetBanNick ( lua_State* luaVM )
{
    CBan* pBan;
    SString strNick;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pBan );
    argStream.ReadString ( strNick );

    if ( !argStream.HasErrors () )
    {
        if ( CStaticFunctionDefinitions::SetBanNick ( pBan, strNick ) )
        {
            lua_pushboolean ( luaVM, true );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Jusonex,项目名称:mtasa-blue,代码行数:23,代码来源:CLuaBanDefs.cpp

示例13: SetUp

int CLuaMatrixDefs::SetUp ( lua_State* luaVM )
{
    CLuaMatrix* pMatrix = NULL;
    CVector vecUp;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pMatrix );
    argStream.ReadVector3D ( vecUp );

    if ( !argStream.HasErrors () )
    {
        pMatrix->vUp = vecUp;
        lua_pushboolean( luaVM, true );
        return 1;
    }
    else
    {
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
    }

    lua_pushboolean( luaVM, false );
    return 1;
}
开发者ID:Anubhav652,项目名称:mtasa-blue,代码行数:23,代码来源:CLuaMatrixDefs.cpp

示例14: TransformDirection

int CLuaMatrixDefs::TransformDirection ( lua_State* luaVM )
{
    CLuaMatrix* pMatrix1 = NULL;
    CVector vector;

    CScriptArgReader argStream ( luaVM );

    argStream.ReadUserData ( pMatrix1 );
    argStream.ReadVector3D ( vector );

    if ( !argStream.HasErrors () )
    {
        lua_pushvector ( luaVM, *pMatrix1 * vector );
        return 1;
    }
    else
    {
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
    }

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Anubhav652,项目名称:mtasa-blue,代码行数:23,代码来源:CLuaMatrixDefs.cpp

示例15: GetObjectScale

int CLuaFunctionDefs::GetObjectScale ( lua_State* luaVM )
{
//  float getObjectScale ( object theObject )
    CClientObject* pObject;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pObject );

    if ( !argStream.HasErrors () )
    {
        float fScale;
        if ( CStaticFunctionDefinitions::GetObjectScale ( *pObject, fScale ) )
        {
            lua_pushnumber ( luaVM, fScale );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, SString ( "Bad argument @ '%s' [%s]", "getObjectScale", *argStream.GetErrorMessage () ) );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:EagleShen,项目名称:MTA,代码行数:23,代码来源:CLuaFunctionDefs.Object.cpp


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