• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# LuaInterface.LuaTable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



LuaTable类属于LuaInterface命名空间,在下文中一共展示了LuaTable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Export

        public static string Export(LuaTable table, int indent)
        {
            StringBuilder sb = new StringBuilder();
              List<DictionaryEntry> items = new List<DictionaryEntry>();
              int maxlen = 0;
              bool allNumber = true;
              int cnt = 1;
              foreach (DictionaryEntry de in table) {
            items.Add(de);
            int len = de.Key.ToString().Length;
            if (len > maxlen) maxlen = len;
            if (!(de.Key is Double) || (int)(double)de.Key != cnt) allNumber = false;
            cnt++;
              }

              items.Sort(SortCompare);

              sb.Append("{\r\n");

              string ind = GetIndentString(indent + 2);
              foreach (DictionaryEntry de in items) {
            if (de.Value is LuaTable) sb.AppendLine();
            sb.Append(ind);

            FormatEntry(sb, maxlen, allNumber, indent, de);

            sb.Append(",\r\n");
            if (de.Value is LuaTable) sb.AppendLine();
              }

              ind = GetIndentString(indent);
              sb.Append(ind + "}");
              return sb.ToString();
        }
开发者ID:ZeroK-RTS,项目名称:SpringRTS-Tools,代码行数:34,代码来源:TableProxy.cs


示例2: Reload

        public void Reload()
        {
            initialized = false;
            string script = resourcePath+ScriptName+".lua";
            // will throw an exception on error...
            object[] res = L.DoFile (script);
            LuaTable env = (LuaTable)res[0];
            // Poor man's OOP! These are all called on self
            //Debug.Log ("here");
            if (env["Update"] != null || env["Start"] != null)
                AssignMethods (env);

            // the script may have an Init method,
            // which expects the object as an argument
            // and returns a table, otherwise we make
            // a new table with a 'this' field
            LuaFunction init = (LuaFunction)env["Init"];
            if (init != null) {
                self = (LuaTable)(init.Call(this)[0]);
            } else {
                L.NewTable(ScriptName);
                self = (LuaTable)L[ScriptName];
                self["this"] = this;
            }
            if (! initialized)
                AssignMethods(self);
            //Debug.Log ("here " + self.ToString ());
            objects[gameObject] = self;
        }
开发者ID:drawcode,项目名称:unityluainterface,代码行数:29,代码来源:LuaUnity.cs


示例3: GetDataTableRow

        /// <summary>
        /// 获取数据行
        /// </summary>
        /// <param name="tablename">数据表名</param>
        /// <param name="keys">数据表主键</param>
        /// <param name="ltReturn">结果数据表</param>
        /// <returns>是否获取成功</returns>
        public bool GetDataTableRow(string tablename, LuaTable keys, ref LuaTable ltReturn)
        {
            string sql = string.Format("SELECT * FROM {0}", tablename);
            DataTable tbl = Helper.GetDataTable(sql, Conn);

            if (tbl.PrimaryKey.Length != keys.Keys.Count)
            {
                MessageBox.Show(string.Format("{0} —— 函数GetDataTableRow断言:{1}\r\n", DateTime.Now, "输入参数keys长度错误。"));
            }

            object[] KEYS = new object[tbl.PrimaryKey.Length];

            for (int i = 0; i < KEYS.Length; i++)
            {
                KEYS[i] = ((LuaTable)keys)[i];
            }

            DataRow row = tbl.Rows.Find(KEYS);

            if (row == null)
            {
                return false;
            }

            foreach (DataColumn col in tbl.Columns)
            {
                ltReturn[col.ColumnName] = (row[col.ColumnName] == DBNull.Value ? null : row[col.ColumnName]);
            }

            return true;
        }
开发者ID:viticm,项目名称:pap2,代码行数:38,代码来源:MainForm.cs


示例4: LoadAsset

        public static Sprite3D LoadAsset(LuaTable el, ContentManager content)
        {
            var texture = content.Load<Texture2D>((string) el["assetName"]);

            var pos = el["pos"] as LuaTable;
            var ypr = el["yawpitchroll"] as LuaTable;
            var scale = el["scale"] as LuaTable;
            if (pos == null || ypr == null || scale == null)
            {
                throw new ContentLoadException();
            }
            var asset = new Sprite3D(
                texture,
                null,
                TableToVector(pos),
                Quaternion.CreateFromYawPitchRoll((float) (double) ypr[1], (float) (double) ypr[2],
                                                  (float) (double) ypr[3]),
                TableToVector(scale)
                );

            var normalMap = el["normalMap"];
            if (normalMap != null)
                asset.NormalMap = content.Load<Texture2D>((string) normalMap);

            return asset;
        }
开发者ID:szyszart,项目名称:Junkyard,代码行数:26,代码来源:LuaMachine.cs


示例5: CreateDelegate

    public static Delegate CreateDelegate(Type t, LuaFunction func, LuaTable self)
    {
        DelegateValue Create = null;

        if (!dict.TryGetValue(t, out Create))
        {
            throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t)));
        }

        if (func != null)
        {
            LuaState state = func.GetLuaState();
            LuaDelegate target = state.GetLuaDelegate(func, self);

            if (target != null)
            {
                return Delegate.CreateDelegate(t, target, target.method);
            }
            else
            {
                Delegate d = Create(func, self, true);
                target = d.Target as LuaDelegate;
                state.AddLuaDelegate(target, func, self);
                return d;
            }
        }

        return Create(func, self, true);
    }
开发者ID:zhangxiangsong,项目名称:some_work,代码行数:29,代码来源:DelegateFactory.cs


示例6: storeRectInTable

 public LuaTable storeRectInTable(System.Drawing.Rectangle r, LuaTable table)
 {
     table["x"] = r.X;
     table["y"] = r.Y;
     table["width"] = r.Width;
     table["height"] = r.Height;
     return table;
 }
开发者ID:zl950402,项目名称:league-tools-revamped,代码行数:8,代码来源:ScriptControl.cs


示例7: SafeRelease

 private void SafeRelease(ref LuaTable table)
 {
     if (table != null)
     {
         table.Dispose();
         table = null;
     }
 }
开发者ID:woshihuo12,项目名称:UnityHello,代码行数:8,代码来源:LuaBehaviour.cs


示例8: getTableFunction

 public static LuaFunction getTableFunction(LuaTable luaTable, string name)
 {
     object obj2 = luaTable.rawget(name);
     if (obj2 is LuaFunction)
     {
         return (LuaFunction) obj2;
     }
     return null;
 }
开发者ID:Evangileon,项目名称:LuaInterface,代码行数:9,代码来源:LuaClassHelper.cs


示例9: Show

 public uint Show(uint oldvalue, LuaTable nums, LuaTable texts)
 {
     Form1 frm = new Form1(oldvalue, nums, texts);
     DialogResult result = frm.ShowDialog();
     if (result == DialogResult.OK)
         return frm.ret;
     else // cancel
         return oldvalue;
 }
开发者ID:viticm,项目名称:pap2,代码行数:9,代码来源:Class1.cs


示例10: LoadLuaTable

	public void LoadLuaTable(LuaTable reqs)
	{
		System.Collections.IEnumerator luatb = reqs.Values.GetEnumerator();
		while (luatb.MoveNext())
		{
			AddReqToQueue((CRequest)luatb.Current);
		}
		BeginQueue();
	}
开发者ID:toophy,项目名称:hugular_cstolua,代码行数:9,代码来源:LHighway.cs


示例11: GetUIPrefab

    public void GetUIPrefab(string assetName, Transform parent, LuaTable luaTable, LuaFunction luaCallBack)
    {
        if (mResManager == null) return;

        string tmpAssetName = assetName;
        if (GameSetting.DevelopMode)
        {
            tmpAssetName = "UIPrefab/" + assetName;
        }
        mResManager.LoadPrefab(assetName + GameSetting.ExtName, tmpAssetName, delegate(UnityEngine.Object[] objs)
        {
            if (objs.Length == 0) return;
            GameObject prefab = objs[0] as GameObject;
            if (prefab == null)
            {
                return;
            }
            GameObject go = UnityEngine.GameObject.Instantiate(prefab) as GameObject;
            go.name = assetName;
            go.layer = LayerMask.NameToLayer("UI");

            Vector3 anchorPos = Vector3.zero;
            Vector2 sizeDel = Vector2.zero;
            Vector3 scale = Vector3.one;

            RectTransform rtTr = go.GetComponent<RectTransform>();
            if (rtTr != null)
            {
                anchorPos = rtTr.anchoredPosition;
                sizeDel = rtTr.sizeDelta;
                scale = rtTr.localScale;
            }

            go.transform.SetParent(parent, false);

            if (rtTr != null)
            {
                rtTr.anchoredPosition = anchorPos;
                rtTr.sizeDelta = sizeDel;
                rtTr.localScale = scale;
            }

            LuaBehaviour tmpBehaviour = go.AddComponent<LuaBehaviour>();
            tmpBehaviour.Init(luaTable);

            if (luaCallBack != null)
            {
                luaCallBack.BeginPCall();
                luaCallBack.Push(go);
                luaCallBack.PCall();
                luaCallBack.EndPCall();
            }
            Debug.Log("CreatePanel::>> " + assetName + " " + prefab);
            //mUIList.Add(go);
        });
    }
开发者ID:woshihuo12,项目名称:UnityHello,代码行数:56,代码来源:GameResFactory.cs


示例12: LuaCSBridgeByteBuffer

        protected LuaTable m_luaTable;      // LuaTable

        public LuaCSBridgeByteBuffer() : 
            base ("NetMsgData")
            //base("ByteBuffer")
        {
            string path = "LuaScript/DataStruct/NetMsgData.lua";
            Ctx.m_instance.m_luaScriptMgr.DoFile(path);
            m_luaTable = Ctx.m_instance.m_luaScriptMgr.GetLuaTable(m_tableName);
            // 设置系统字节序
            setSysEndian((int)SystemEndian.m_sEndian);
        }
开发者ID:zhutaorun,项目名称:unitygame,代码行数:12,代码来源:LuaCSBridgeByteBuffer.cs


示例13: LuaEvent

        //LuaFunction _call = null;

        public LuaEvent(LuaTable table)            
        {
            self = table;
            luaState = table.GetLuaState();
            self.AddRef();

            _add = self.RawGetLuaFunction("Add");
            _remove = self.RawGetLuaFunction("Remove");
            //_call = self.RawGetLuaFunction("__call");            
        }
开发者ID:benbon,项目名称:tolua,代码行数:12,代码来源:LuaEvent.cs


示例14: ValidateAndStore

 protected override void ValidateAndStore(LuaTable data)
 {
     try
     {
         gravity = (float) (double) data["gravity"];
     }
     catch
     {
         throw new ArgumentException("Invalid unit description.");
     }
 }
开发者ID:szyszart,项目名称:Junkyard,代码行数:11,代码来源:ProjectileFactory.cs


示例15: CreateDelegate

    public static Delegate CreateDelegate(Type t, LuaFunction func, LuaTable self)
    {
        DelegateValue create = null;

        if (!dict.TryGetValue(t, out create))
        {
            throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t)));
        }

        return create(func, self, true);
    }
开发者ID:woshihuo12,项目名称:UnityHello,代码行数:11,代码来源:DelegateFactory.cs


示例16: registerWidgetEventByTable

        // 根据表注册 UI 事件, LuaTable 的格式如下 luaTable {name="Panel_Name", BtnClickTable={"ui/click", "ui/tab"} ImageClickTable={"ui/click", "ui/tab"}}
        public void registerWidgetEventByTable(LuaTable luaTable)
        {
            m_form.formName = luaTable["name"] as string;
            LuaTable btnClickTable = luaTable["BtnClickTable"] as LuaTable;

            string[] btnArray = btnClickTable.ToArray<string>();
            m_form.registerBtnClickEventByList(btnArray);

            // LuaTable imageClickTable = luaTable["ImageClickTable"] as LuaTable;
            // string[] imageArary = imageClickTable.ToArray<string>();
            // m_form.registerImageClickEventByList(imageArary);
        }
开发者ID:zhutaorun,项目名称:unitygame,代码行数:13,代码来源:LuaCSBridgeForm.cs


示例17: LuaEvent

        //LuaFunction _call = null;

        public LuaEvent(LuaTable table)            
        {
            self = table;
            luaState = table.GetLuaState();
            self.AddRef();

            LuaTable meta = self.GetMetaTable();
            _add = meta.RawGetLuaFunction("Add");
            _remove = meta.RawGetLuaFunction("Remove");
            meta.Dispose();
            meta = null;
            //_call = self.RawGetLuaFunction("__call");            
        }
开发者ID:zlanr,项目名称:tolua,代码行数:15,代码来源:LuaEvent.cs


示例18: Add

        public void Add(LuaFunction func, LuaTable obj)
        {
            if (func == null)
            {
                return;
            }

            _add.BeginPCall();
            _add.Push(self);
            _add.Push(func);
            _add.Push(obj);
            _add.PCall();
            _add.EndPCall();
        }
开发者ID:zlanr,项目名称:tolua,代码行数:14,代码来源:LuaEvent.cs


示例19: ValidateAndStore

        protected override void ValidateAndStore(LuaTable data)
        {
            base.ValidateAndStore(data);

            try
            {
                Speed = (float) (double) data["speed"];
                AttackRange = (float) (double) data["attack_range"];
                InitialHP = (int) (double) data["initial_hp"];
            }
            catch
            {
                throw new ArgumentException("Invalid unit description.");
            }
        }
开发者ID:szyszart,项目名称:Junkyard,代码行数:15,代码来源:GenuineBattleUnitFactory.cs


示例20: RunLuaFile

    void RunLuaFile()
    {
        if (luaFile == null || string.IsNullOrEmpty(luaFile.text))
            return;

        object[] luaRet = GameManager.Instance.LuaMgr.DoString(luaFile.text);
        if (luaRet != null && luaRet.Length >= 1)
        {
            this.LuaModule = luaRet[0] as LuaTable;
            this.LuaModule["gameObject"] = this.gameObject;
            this.LuaModule["transform"] = this.transform;
        }
        else
        {
            Debug.LogError("Lua脚本没有返回Table对象:" + luaFile.name);
        }
    }
开发者ID:zhlikezhz,项目名称:Game,代码行数:17,代码来源:LuaDelegate.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LuaInterface.ObjectTranslator类代码示例发布时间:2022-05-26
下一篇:
C# LuaInterface.LuaFunction类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap