Beispiel #1
0
        public object[] CallTableFunc(string strFullName, params object[] args)
        {
            object[] pRtnObjs = null;
            do
            {
                if (strFullName == null)
                {
                    break;
                }

                int dwLastSemIndex = -1;
                int dwSemNum       = 0;
                int dwLenMax       = strFullName.Length;
                {
                    for (int i = 0; i < dwLenMax; ++i)
                    {
                        if (strFullName[i] == ':')
                        {
                            dwLastSemIndex = i;
                            dwSemNum++;
                        }
                    }
                }
                //错误格式
                if (dwSemNum >= 2 || dwLastSemIndex == 0 || dwLastSemIndex >= dwLenMax - 1)
                {
                    break;
                }

                if (dwLastSemIndex > 0)
                {
                    bool bCallSucFlg = false;
                    {
                        string strFuncName  = strFullName.Substring(dwLastSemIndex + 1, dwLenMax - dwLastSemIndex - 1);
                        string strTableName = strFullName.Substring(0, dwLastSemIndex);

                        try
                        {
                            LuaTable pCurTable = m_LuaState.GetTable(strTableName);
                            if (pCurTable != null)
                            {
                                pRtnObjs    = pCurTable.CallTableFunc(strFuncName, args);
                                bCallSucFlg = true;
                            }

                            pCurTable.Dispose();
                            pCurTable = null;
                        }
                        catch (System.Exception ex)
                        {
                            Debug.LogError(ex.ToString());
                        }
                    }

                    if (!bCallSucFlg)
                    {
                        Debugger.LogError(string.Format("lua CallTableFunc fail={0}", strFullName));
                    }
                }
                else
                {
                    Debug.LogWarning("It's not a dynamic table, please use CallMethod instead");
                }
            } while (false);

            return(pRtnObjs);
        }