int CLuaTextDefs::textCreateTextItem ( lua_State* luaVM )
{
    
    SString strText, strHorzAlign, strVertAlign;
    float fX, fY, fScale;
    int iPriority;
    SColorRGBA color ( 255, 255, 255, 255 );
    unsigned char ucShadowAlpha;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadString ( strText, "" );
    argStream.ReadNumber ( fX, 0.5f );
    argStream.ReadNumber ( fY, 0.5f );

    if ( argStream.NextIsString( ) )
    {
        SString strPriority;
        argStream.ReadString ( strPriority );

        if ( strPriority == "high" )        iPriority = PRIORITY_HIGH;
        else if ( strPriority == "medium" ) iPriority = PRIORITY_MEDIUM;
        else                                iPriority = PRIORITY_LOW;

    }
    else
    {
        argStream.ReadNumber(iPriority, PRIORITY_LOW);
    }
    
    argStream.ReadNumber( color.R, 255 );
    argStream.ReadNumber( color.G, 255 );
    argStream.ReadNumber( color.B, 255 );
    argStream.ReadNumber( color.A, 255 );
    argStream.ReadNumber( fScale, 1 );
    argStream.ReadString( strHorzAlign, "left" );
    argStream.ReadString( strVertAlign, "top" );
    argStream.ReadNumber( ucShadowAlpha, 0);

    if ( !argStream.HasErrors ( ) )
    {
        unsigned char ucFormat = 0; 
        if ( strHorzAlign == "center" ) 
            ucFormat |= 0x00000001; // DT_CENTER
        else if ( strHorzAlign == "right" )
            ucFormat |= 0x00000002; // DT_RIGHT

        if ( strVertAlign == "center" )
            ucFormat |= 0x00000004; // DT_VCENTER
        else if ( strVertAlign == "bottom" )
            ucFormat |= 0x00000008; // DT_BOTTOM
        
        // Grab our virtual machine
        CLuaMain* luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
        if ( luaMain )
        {
            CTextItem* pTextItem = luaMain->CreateTextItem ( strText, fX, fY, (eTextPriority) iPriority, color, fScale, ucFormat, ucShadowAlpha );
            lua_pushtextitem ( luaVM, pTextItem );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );


    lua_pushboolean ( luaVM, false );
    return 1;
}