コード例 #1
0
 public static int SetEventParamNames(IntPtr l)
 {
     if (l != IntPtr.Zero)
     {
         int token = CrossEvent.TOKEN_CALL;
         var top   = l.gettop();
         CrossEvent.SetParamCount(token, top);
         for (int i = 1; i <= top; ++i)
         {
             var name = l.GetLua <string>(i);
             CrossEvent.SetValStr(name);
             CrossEvent.SetParamName(token, i - 1);
         }
     }
     return(0);
 }
コード例 #2
0
 public static int TrigLuaEvent(IntPtr l)
 {
     if (l != IntPtr.Zero)
     {
         var cate = l.GetLua <string>(1);
         if (cate == null)
         {
             return(0);
         }
         int token = CrossEvent.TOKEN_CALL;
         var top   = l.gettop();
         CrossEvent.SetParamCount(token, Math.Max(0, top - 1));
         for (int i = 2; i <= top; ++i)
         {
             if (l.istable(i))
             {
                 CrossEvent.ContextExchangeObj = GetParams(l, i);
             }
             else
             {
                 CrossEvent.ContextExchangeObj = l.GetLua(i);
             }
             CrossEvent.SetParam(token, i - 2);
         }
         CrossEvent.TrigEvent(cate);
         int rvcnt = CrossEvent.GetParamCount(token);
         for (int i = 0; i < rvcnt; ++i)
         {
             CrossEvent.GetParam(token, i);
             if (CrossEvent.ContextExchangeObj is List <CrossEvent.EventParam> )
             {
                 PushParams(l, CrossEvent.ContextExchangeObj as List <CrossEvent.EventParam>);
             }
             else
             {
                 l.PushLua(CrossEvent.ContextExchangeObj);
             }
         }
         return(l.gettop() - top);
     }
     return(0);
 }