當前位置: 首頁>>代碼示例>>C#>>正文


C# LuaTable.AddValue方法代碼示例

本文整理匯總了C#中SharpLua.LuaTypes.LuaTable.AddValue方法的典型用法代碼示例。如果您正苦於以下問題:C# LuaTable.AddValue方法的具體用法?C# LuaTable.AddValue怎麽用?C# LuaTable.AddValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SharpLua.LuaTypes.LuaTable的用法示例。


在下文中一共展示了LuaTable.AddValue方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: QuaternionToTable

        public static LuaTable QuaternionToTable(Quaternion q)
        {
            LuaTable t = new LuaTable();

            t.AddValue(new LuaNumber(q.x));
            t.AddValue(new LuaNumber(q.y));
            t.AddValue(new LuaNumber(q.z));
            t.AddValue(new LuaNumber(q.w));

            return t;
        }
開發者ID:Majiir,項目名稱:MuMechLib,代碼行數:11,代碼來源:LuaUtils.cs

示例2: Evaluate

        public override LuaValue Evaluate(LuaTable enviroment)
        {
            LuaTable table = new LuaTable();

            foreach (Field field in this.FieldList)
            {
                NameValue nameValue = field as NameValue;
                if (nameValue != null)
                {
                    table.SetNameValue(nameValue.Name, nameValue.Value.Evaluate(enviroment));
                    continue;
                }

                KeyValue keyValue = field as KeyValue;
                if (keyValue != null)
                {
                    table.SetKeyValue(
                        keyValue.Key.Evaluate(enviroment),
                        keyValue.Value.Evaluate(enviroment));
                    continue;
                }

                ItemValue itemValue = field as ItemValue;
                if (itemValue != null)
                {
                    table.AddValue(itemValue.Value.Evaluate(enviroment));
                    continue;
                }
            }

            return table;
        }
開發者ID:Majiir,項目名稱:MuMechLib,代碼行數:32,代碼來源:TableConstructor.cs

示例3: GetParentClasses

 public LuaValue GetParentClasses(LuaValue[] args)
 {
     LuaTable t = new LuaTable();
     foreach (LuaClass p in ParentClasses)
         t.AddValue(p);
     return t;
 }
開發者ID:Majiir,項目名稱:MuMechLib,代碼行數:7,代碼來源:LuaClass.cs

示例4: ToLuaTable

        public static LuaTable ToLuaTable(object o)
        {
            LuaTable ret = new LuaTable();

            // check if Dictionary...
            System.Collections.IDictionary dict = o as System.Collections.IDictionary;
            if (dict != null)
            {
                foreach (object obj in dict.Keys)
                {
                    ret.SetKeyValue(ToLuaValue(obj), ToLuaValue(dict[obj]));
                }
                return ret;
            }

            System.Collections.IEnumerable ie = (o as System.Collections.IEnumerable);
            if (ie != null)
            {
                foreach (object obj in ie)
                {
                    ret.AddValue(ToLuaValue(obj));
                }
                return ret;
            }

            // check if <type>...
            // not an array type
            ret.AddValue(ToLuaValue(o));
            return ret;
        }
開發者ID:chenzuo,項目名稱:SharpLua,代碼行數:30,代碼來源:ObjectToLua.cs

示例5: ToLuaValue

 public static LuaValue ToLuaValue(object value)
 {
     if ((value as LuaValue) != null)
         return value as LuaValue;
     if (value is int || value is double)
     {
         return new LuaNumber(Convert.ToDouble(value));
     }
     else if (value is string)
     {
         return new LuaString((string)value);
     }
     else if (value is bool)
     {
         return LuaBoolean.From((bool)value);
     }
     else if (value == null)
     {
         return LuaNil.Nil;
     }
     else if (value.GetType().IsEnum)
     {
         return new LuaString(value.ToString());
     }
     else if (value.GetType().IsArray)
     {
         LuaTable table = new LuaTable();
         foreach (var item in (value as Array))
         {
             table.AddValue(ToLuaValue(item));
         }
         return table;
     }
     else if (value is LuaValue)
     {
         return (LuaValue)value;
     }
     else
     {
         LuaUserdata data = new LuaUserdata(value);
         data.MetaTable = GetControlMetaTable();
         return data;
     }
 }
開發者ID:chenzuo,項目名稱:SharpLua,代碼行數:44,代碼來源:ObjectToLua.cs

示例6: Vector3dToTable

        public static LuaTable Vector3dToTable(Vector3d v)
        {
            LuaTable t = new LuaTable();

            t.AddValue(new LuaNumber(v.x));
            t.AddValue(new LuaNumber(v.y));
            t.AddValue(new LuaNumber(v.z));

            return t;
        }
開發者ID:Majiir,項目名稱:MuMechLib,代碼行數:10,代碼來源:LuaUtils.cs

示例7: RegisterFunctions

        public static void RegisterFunctions(LuaTable module)
        {
            // cpath -> cspath?
            module.SetNameValue("cpath", new LuaString(".\\?;.\\?.dll;.\\?.exe"));
            module.SetNameValue("path", new LuaString(".\\?;.\\?.lua;.\\?.slua;.\\?.wlua;" + System.Environment.GetEnvironmentVariable("LUA_PATH")));
            module.SetNameValue("bpath", new LuaString(".\\?;.\\?.luac;.\\?.out;.\\?.sluac"));
            module.SetNameValue("loaded", new LuaTable());
            module.SetNameValue("preload", new LuaTable());
            module.Register("seeall", SeeAll);

            // Load package loader functions
            LuaTable loaderfunctions = new LuaTable();
            loaderfunctions.Register("PreloadSearcher", new LuaFunc(delegate(LuaValue[] args) {
                                                                        LuaTable t = (LuaRuntime.GlobalEnvironment.GetValue("package") as LuaTable).GetValue("preload") as LuaTable;
                                                                        string mod = (args[0] as LuaString).Text;
                                                                        LuaValue v = t.GetValue(mod);
                                                                        if (v != null && v != LuaNil.Nil)
                                                                            return new LuaMultiValue(new LuaValue[] {LuaBoolean.True, v as LuaTable});
                                                                        else
                                                                            return new LuaMultiValue(new LuaValue[] {LuaBoolean.False});
                                                                    }));

            loaderfunctions.Register("PathSearcher", new LuaFunc(delegate(LuaValue[] args)
                                                                 {
                                                                     // get package.path variable
                                                                     string path = (LuaRuntime.GlobalEnvironment.GetValue("package") as LuaTable).GetValue("path").Value.ToString();
                                                                     // split into paths
                                                                     string[] paths = path.Split(';');
                                                                     // check file names
                                                                     foreach (string p in paths)
                                                                     {
                                                                         foreach (LuaValue arg in args)
                                                                         {
                                                                             string sfn = arg.Value.ToString();
                                                                             string fn = p.Replace("?", sfn);
                                                                             if (File.Exists<PackageLib>(fn))
                                                                             {
                                                                                 LuaTable m = new LuaTable();
                                                                                 m.AddValue(LuaRuntime.RunFile(fn, LuaRuntime.GlobalEnvironment));
                                                                                 return new LuaMultiValue(new LuaValue[] { LuaBoolean.True, LuaRuntime.GlobalEnvironment.GetValue(fn) }); // Path.GetFileNameWithoutExtension(fn)
                                                                             }
                                                                         }
                                                                     }
                                                                     return new LuaMultiValue(new LuaValue[] {LuaBoolean.False});
                                                                 }));

            loaderfunctions.Register("CSPathSearcher", new LuaFunc(delegate(LuaValue[] args)
                                                                   {
                                                                       // get package.path variable
                                                                       string path = (LuaRuntime.GlobalEnvironment.GetValue("package") as LuaTable).GetValue("cpath").Value.ToString();
                                                                       // split into paths
                                                                       string[] paths = path.Split(';');
                                                                       // check file names
                                                                       foreach (string p in paths)
                                                                       {
                                                                           foreach (LuaValue arg in args)
                                                                           {
                                                                               string sfn = arg.Value.ToString();
                                                                               string fn = p.Replace("?", sfn);
                                                                               if (File.Exists<PackageLib>(fn))
                                                                               {
                                                                                   A8Console.WriteLine("Loading file '" + fn + "'...");
                                                                                   string[] modules = ExternalLibraryLoader.Load(fn);
                                                                                   LuaTable t = LuaRuntime.GlobalEnvironment.GetValue(modules[0]) as LuaTable;

                                                                                   return new LuaMultiValue(new LuaValue[] {LuaBoolean.True, t});
                                                                               }
                                                                           }
                                                                       }
                                                                       return new LuaMultiValue(new LuaValue[] {LuaBoolean.False});
                                                                   }));
            loaderfunctions.Register("BinarySearcher", new LuaFunc(delegate(LuaValue[] args)
                                                                   {
                                                                     // get package.path variable
                                                                     string path = (LuaRuntime.GlobalEnvironment.GetValue("package") as LuaTable).GetValue("bpath").Value.ToString();
                                                                     // split into paths
                                                                     string[] paths = path.Split(';');
                                                                     // check file names
                                                                     foreach (string p in paths)
                                                                     {
                                                                         foreach (LuaValue arg in args)
                                                                         {
                                                                             string sfn = arg.Value.ToString();
                                                                             string fn = p.Replace("?", sfn);
                                                                             if (File.Exists<PackageLib>(fn))
                                                                             {
                                                                                 LuaTable m = new LuaTable();
                                                                                 bool isBreak;
                                                                                 m.AddValue((Serializer.Deserialize(fn) as AST.Chunk).Execute(LuaRuntime.GlobalEnvironment, out isBreak));
                                                                                 return new LuaMultiValue(new LuaValue[] { LuaBoolean.True, LuaRuntime.GlobalEnvironment.GetValue(fn) }); // Path.GetFileNameWithoutExtension(fn)
                                                                             }
                                                                         }
                                                                     }
                                                                     return new LuaMultiValue(new LuaValue[] {LuaBoolean.False});
                                                                   }));
            module.SetNameValue("loaders", loaderfunctions);
            module.Register("loadlib", new LuaFunc((LuaValue[] args) =>
                                                   {
                                                       return args[0];
                                                   }));
//.........這裏部分代碼省略.........
開發者ID:Majiir,項目名稱:MuMechLib,代碼行數:101,代碼來源:PackageLib.cs

示例8: GetMatches

 private static LuaTable GetMatches(LuaValue[] args)
 {
     LuaTable t = new LuaTable();
     
     string s = (args[0] as LuaString).Text;
     string format = (args[1] as LuaString).Text;
     
     Regex re = new Regex(format);
     Match m = re.Match(s);
     
     while (m.Success)
     {
         for (int i = 0; i < m.Groups.Count; i++)
         {
             Group g = m.Groups[i];
             CaptureCollection cc = g.Captures;
             for (int j = 0; j < cc.Count; j++)
             {
                 Capture c = cc[j];
                 t.AddValue(new LuaString(c.Value));
             }
         }
         m = m.NextMatch();
     }
     return t;
 }
開發者ID:chenzuo,項目名稱:SharpLua,代碼行數:26,代碼來源:StringLib.cs


注:本文中的SharpLua.LuaTypes.LuaTable.AddValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。