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


C# Lua.GetTable方法代码示例

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


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

示例1: Init

 public void Init(string strAPIInfoFile)
 {
     m_strCode = "";
     m_strAPIInfoFile = strAPIInfoFile;
     m_lua = new Lua();
     m_lua.DoFile(m_strAPIInfoFile);
     m_luatable = m_lua.GetTable("APIInfo");
     m_nClassCount = m_luatable.Keys.Count;
     m_strClass = new string[m_nClassCount];
     m_strClassInCode = new string[m_nClassCount];
     m_strIniFileName = Application.StartupPath + "\\Plugins\\LuaCheck\\API.temp.lua";
     m_lua1 = new Lua();
     m_lua1.DoFile(m_strIniFileName);
     int n = 0;
     foreach (string str in m_luatable.Keys)
     {
         m_strClass[n] = (string)(((LuaTable)m_luatable[str])["Name"]);
         n++;
     }
     
     //object ob;
     //foreach (ob in m_luatable)
     //{
     //    strClass[] = ((LuaTable)ob)["Name"];
     
     //}
     //object ob = m_luatable["1"];
     //object ob1 = ((LuaTable)ob)["Name"];
 }
开发者ID:viticm,项目名称:pap2,代码行数:29,代码来源:CodeBuilder.cs

示例2: load

        /// <summary>
        /// Loads a world from a lua file
        /// </summary>
        /// <param name="filename">file to load the world from</param>
        /// <returns>true on success</returns>
        public bool load(string filename)
        {
            this.fname = filename;

            Lua lua = new Lua();
            var result = lua.DoFile(filename);
            foreach (DictionaryEntry member in lua.GetTable("world_data"))
            {
                if (member.Key.ToString() == "width")
                {
                    this.width = Convert.ToInt32(member.Value);
                }
                else if (member.Key.ToString() == "height")
                {
                    this.height = Convert.ToInt32(member.Value);
                }
                if (member.Key.ToString() == "paths")
                {
                    collision_segment = new ArrayList();
                    LuaTable paths = (LuaTable)member.Value;
                    foreach (DictionaryEntry path in paths)
                    {
                        ArrayList collision_path = new ArrayList();
                        LuaTable p = (LuaTable)path.Value;
                        foreach (DictionaryEntry point in p)
                        {
                            LuaTable point_data = (LuaTable)point.Value;
                            int x = Convert.ToInt32(point_data.Values.Cast<double>().ElementAt(0) * ppu);
                            int y = Convert.ToInt32(point_data.Values.Cast<double>().ElementAt(1) * ppu);
                            Console.WriteLine("X:" + x + ", Y:" + y);
                            collision_path.Add(new Point(x, y));
                        }
                        collision_segment.Add(collision_path);
                    }

                }
            }
            return true;
        }
开发者ID:didius,项目名称:platinumEditor,代码行数:44,代码来源:World.cs

示例3: loadFile


//.........这里部分代码省略.........
                                                     + "Value " + s + " is ignored.");
                            else
                                PaletteData.PalOrder = (PaletteOrder)Enum.Parse(typeof(PaletteOrder), s);
                        }
                        #endregion

                        #region alpha location
                        if (interp["alphaAtStart"] != null)
                        {
                            bool atStart = (bool)interp["alphaAtStart"];
                            PaletteData.AlphaSettings.Location = atStart ? AlphaLocation.START : AlphaLocation.END;
                        }
                        #endregion

                        #region ignore alpha
                        if (interp["ignoreAlpha"] != null)
                        {
                            bool ignore = (bool)interp["ignoreAlpha"];
                            PaletteData.AlphaSettings.IgnoreAlpha = ignore;
                        }
                        #endregion

                        #region enable stretch
                        if (interp["enableAlphaStrech"] != null)
                        {
                            bool enable = (bool)interp["enableAlphaStrech"];
                            PaletteData.AlphaSettings.Stretch = enable;
                        }
                        #endregion

                        #region stretch settings
                        if (interp["alphaStretch"] != null)
                        {
                            LuaTable t = interp.GetTable("alphaStretch");

                            if (t["min"] != null)
                                PaletteData.AlphaSettings.Minimum = (byte)(double)t["min"];
                            else if(t[0] != null)
                                PaletteData.AlphaSettings.Minimum = (byte)(double)t[0];

                            if (t["max"] != null)
                                PaletteData.AlphaSettings.Maximum = (byte)(double)t["max"];
                            else if (t[0] != null)
                                PaletteData.AlphaSettings.Maximum = (byte)(double)t[1];
                        }
                        #endregion
                    }

                    #region Endianness
                    if (interp["bigendian"] != null)
                    {
                        bool isBE = (bool)interp["bigendian"];
                        switch (this.Parent.BindingType)
                        {
                            case BindingType.GRAPHICS:
                                GraphicsData.IsBigEndian = isBE; break;
                            case BindingType.PALETTE:
                                PaletteData.IsBigEndian = isBE; break;
                        }
                    }
                    #endregion

                    #region tile size
                    if (interp["tilesize"] != null)
                    {
                        System.Drawing.Point size, oldSize;
开发者ID:puggsoy,项目名称:tiledggd-pe-,代码行数:67,代码来源:LuaTool.cs

示例4: Run

 public void Run()
 {
     Lua lua = new Lua();
     try
     {
         lua.DoFile(m_strExecFile);
     }
     catch (Exception Ex)
     {
         Console.WriteLine(Ex.Message);
         return;
     }
     LuaTable luaTable = lua.GetTable("EVENT_LIST");
     foreach (object Key in luaTable.Keys)
     {
         string strEventFunction = (string)luaTable[Key];
         //整理参数格式为   “param1, param2, param3, ”
         int nIndexP = strEventFunction.IndexOf("(") + 1;
         int nIndexE = strEventFunction.IndexOf(")");
         string strFunctionName = strEventFunction.Substring(0, nIndexP - 1);
         string strParam = strEventFunction.Substring(nIndexP, nIndexE - nIndexP) + ", ";
         nIndexP = 0;
         nIndexE = 0;
         strFunctionName = strFunctionName + "(";
         while (true)
         {
             nIndexP = nIndexE;
             nIndexE = strParam.IndexOf(", ", nIndexP) + 2;
             if (nIndexE == 1)
             {
                 break;
             }
             string strParamName = strParam.Substring(nIndexP, nIndexE - 2 - nIndexP);
             string sb = GetStringFromFile("GetParam", strParamName, "nil");
             if (sb == "nil")
             {
                 MessageBox.Show("配置文件中无法找到逻辑检查代入参数:" + strParamName);
             }
             strFunctionName = strFunctionName + sb + ", ";
         }
         if (strEventFunction.IndexOf("(") + 1 != strEventFunction.IndexOf(")"))
         {
             strFunctionName = strFunctionName.Substring(0, strFunctionName.Length - 2);
         }
         strFunctionName = strFunctionName + ")";
         try
         {
              lua.DoString(strFunctionName);
         }
         catch (Exception Ex)
         {   
             //过滤因为调用了不存在的Event引起的错误
             string strFunc = strFunctionName.Substring(0, strFunctionName.IndexOf("("));
             int nIndexEx = Ex.Message.IndexOf(strFunc);
             if (nIndexEx == -1)
             {
                 Console.WriteLine(Ex.Message);
             }
         }
     }
 }
开发者ID:viticm,项目名称:pap2,代码行数:61,代码来源:LuaBuilder.cs

示例5: Export

        private void Export(string strMap)
        {
            string strPath = @"D:\Kingsoft\sword3-products\trunk\client\scripts\Map\" + strMap;
            Lua mLua = new Lua();
            mLua.DoFile(strPath + @"\include\对话.ls");

            string[] as_head = new string[]
            { 
                "COMMON_NPC_STRING",
                "COMMON_DOODAD_STRING",
                "COMMON_ITEM_STRING",
                "COMMON_TRAP_STRING",
                "COMMON_OTHER_STRING",

                "WANHUA_DOODAD_STRING",
                "WANHUA_ITEM_STRING",
                "WANHUA_COMMON_NPC_STRING"
            };           

            //遍历文件
            foreach(FileInfo fi in new DirectoryInfo(strPath).GetFiles("*.*", SearchOption.AllDirectories))
            {
                string strCode = Helper.FileToString(fi.FullName);
                if(fi.Name.ToLower().EndsWith(".lua"))
                {
                    //遍历表名
                    foreach(string strHead in as_head)
                    {
                        LuaTable lt_head = mLua.GetTable(strHead);
                        if (lt_head == null) continue;
                        //遍历某个表
                        foreach (string strKey in lt_head.Keys)
                        {
                            if (lt_head[strKey] is LuaTable)
                            {
                                string strPreDim = "";
                                LuaTable lt = lt_head[strKey] as LuaTable;
                                strPreDim = "LS_" + strKey + " = {";
                                foreach(object substring in lt.Values)
                                {
                                    strPreDim += "\r\n\t\"" + substring.ToString().Replace("\n", "\\n") + "\",";
                                }
                                if(strCode.IndexOf(strHead + "[\"" + strKey + "\"]") != -1)
                                    strCode = strPreDim.TrimEnd(new char[] { ',' }) + "\r\n}\r\n" + strCode;
                                strCode = strCode.Replace("math.random(", "Random(");
                                strCode = strCode.Replace(strHead + "[\"" + strKey + "\"]", "LS_" + strKey);                         
                            }
                            else if(lt_head[strKey] is string)
                            {
                                strCode = strCode.Replace(strHead + "[\"" + strKey + "\"]", "\"" + lt_head[strKey].ToString().Replace("\n", "\\n") + "\"");
                            }
                        }
                    }
                    strCode = strCode.Replace("Include(\"scripts/Map/" + strMap + "/include/对话.ls\");", "");
                }
                else if (fi.Name == "对话.ls")
                {
                    //donothing
                    continue;
                }
                else if (fi.Name.ToLower().EndsWith(".ls"))
                {
                    //对于用户自定义ls,不管了
                }
                else
                {
                    //SVN文件,不导
                    continue;
                }
                
                //转换后的东东存成文件
                string strOutPath = fi.FullName.Replace(strPath, @"D:\xxx\" + strMap);
                Helper.WriteStringToFile(strCode, strOutPath);
            }


        }
开发者ID:viticm,项目名称:pap2,代码行数:77,代码来源:ImportForm.cs

示例6: GetStringFromFile

 private string GetStringFromFile(string strTableName, string strFieldName, string strDefReturn)
 {
     Lua lua = new Lua();
     lua.DoFile(m_strIniFile);
     LuaTable tbl = lua.GetTable(strTableName);
     string strReturn = "";
     try
     {
         strReturn = (string)tbl[strFieldName];
     }
     catch (Exception e)
     {
         return strDefReturn;
     }
     return strReturn == null ? strDefReturn : strReturn;
 }
开发者ID:viticm,项目名称:pap2,代码行数:16,代码来源:LuaBuilder.cs

示例7: InitLogicManager

        /// <summary>
        /// 初始化逻辑管理器
        /// </summary>
        public void InitLogicManager()
        {
            string filePath = Path.Combine(Application.StartupPath, configFileName);
            
            if (File.Exists(filePath))
            {
                Lua lua = new Lua();

                lua.DoFile(filePath);
                LuaTable configTable = lua.GetTable("Config") as LuaTable;

                string[] diagramNameArray = new string[maxDiagramCount];

                foreach (object key in configTable.Keys)
                {
                    LuaTable logicManagerTable = configTable[key] as LuaTable;

                    if (logicManagerTable != null)
                    {
                        // 读取逻辑管理器信息
                        string logicManagerFilePath = logicManagerTable["LogicManagerFilePath"] as string;
                        string logicManagerClassName = logicManagerTable["LogicManagerClassName"] as string;
                        LogicBaseManager logicManager = null;

                        if (!string.IsNullOrEmpty(logicManagerFilePath) && !string.IsNullOrEmpty(logicManagerClassName))
                        {
                            logicManager = LoadLogicManager(logicManagerFilePath, logicManagerClassName);
                        }
                        else
                        {
                            logicManager = new LogicBaseManager();
                        }

                        // 读取显示名称
                        string logicManagerDisplayName = logicManagerTable["DisplayName"] as string;

                        if (!string.IsNullOrEmpty(logicManagerDisplayName))
                        {
                            logicManager.DisplayName = logicManagerDisplayName;
                        }                        

                        // 读取脚本生成插件信息
                        string compilerFilePath = logicManagerTable["CompilerFilePath"] as string;
                        string compilerClassName = logicManagerTable["CompilerClassName"] as string;

                        if (!string.IsNullOrEmpty(compilerFilePath) && !string.IsNullOrEmpty(compilerClassName))
                        {
                            logicManager.InitCompiler(compilerFilePath, compilerClassName);
                        }

                        // 检查是否是默认分类
                        int index = (int)(double)logicManagerTable["Index"];
                        diagramNameArray[index - 1] = logicManagerDisplayName;                        

                        // 读取数据元信息
                        LuaTable dataElementGroupTable = logicManagerTable["DataElement"] as LuaTable;

                        if (dataElementGroupTable != null)
                        {
                            foreach (object graphType in dataElementGroupTable.Keys)
                            {
                                LuaTable dataElementConfigTable = dataElementGroupTable[graphType] as LuaTable;

                                if (dataElementConfigTable != null)
                                {
                                    string dataElementFilePath = dataElementConfigTable["FilePath"] as string;
                                    string dataElementClassName = dataElementConfigTable["ClassName"] as string;

                                    logicManager.RegistDataElementInfo(graphType as string, dataElementFilePath, dataElementClassName);
                                }                                
                            }
                        }

                        logicManagerDictionary[logicManager.DisplayName] = logicManager;
                    }                    
                }

                foreach (string displayName in diagramNameArray)
                {
                    if (displayName != null)
                    {
                        diagramNameList.Add(displayName);
                    }
                }                
            }            
        }
开发者ID:viticm,项目名称:pap2,代码行数:89,代码来源:Helper.cs


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