public static int print(IntPtr L) { if (HobaDebuger.GameLogLevel < LogLevel.Log) { return(0); } // For each argument we'll 'tostring' it int n = LuaDLL.lua_gettop(L); string s = String.Empty; LuaDLL.lua_getglobal(L, "tostring"); for (int i = 1; i <= n; i++) { LuaDLL.lua_pushvalue(L, -1); /* function to be called */ LuaDLL.lua_pushvalue(L, i); /* value to print */ LuaDLL.lua_call(L, 1, 1); string ret = LuaDLL.lua_tostring(L, -1); if (ret == null) { HobaDebuger.LogError("!!!! lua print return null*"); } else { s += ret; } if (i < n) { s += "\t"; } LuaDLL.lua_pop(L, 1); /* pop result */ } #if !SERVER_USE if (!EntryPoint.Instance.IsInited) { LuaDLL.HOBA_LogString(HobaText.Format("print LUA: {0}", s)); } #endif HobaDebuger.LogFormat("LUA: {0}", s); return(0); }
public static int print(IntPtr L) { int num = LuaDLL.lua_gettop(L); string text = string.Empty; LuaDLL.lua_getglobal(L, "tostring"); for (int i = 1; i <= num; i++) { LuaDLL.lua_pushvalue(L, -1); LuaDLL.lua_pushvalue(L, i); LuaDLL.lua_call(L, 1, 1); if (i > 1) { text += "\t"; } text += LuaDLL.lua_tostring(L, -1); LuaDLL.lua_pop(L, 1); } Debug.Log("LUA: " + text); return(0); }
public static void Push(IntPtr L, Touch t, int flag) { LuaState state = LuaState.Get(L); LuaDLL.lua_getref(L, state.PackTouch); LuaDLL.lua_pushinteger(L, t.fingerId); if ((flag & TouchBits.Position) != 0) { Push(L, t.position); } else { LuaDLL.lua_pushnil(L); } if ((flag & TouchBits.RawPosition) != 0) { Push(L, t.rawPosition); } else { LuaDLL.lua_pushnil(L); } if ((flag & TouchBits.DeltaPosition) != 0) { Push(L, t.deltaPosition); } else { LuaDLL.lua_pushnil(L); } LuaDLL.lua_pushnumber(L, t.deltaTime); LuaDLL.lua_pushinteger(L, t.tapCount); LuaDLL.lua_pushinteger(L, (int)t.phase); LuaDLL.lua_call(L, 7, -1); }
public static int errorFunc_traceback(IntPtr L) { if (!LuaDLL.lua_isstring(L, 1)) /* 'message' not a string? */ { return(1); /* keep it intact */ } LuaDLL.lua_getfield(L, LuaIndexes.LUA_GLOBALSINDEX, "debug"); if (LuaDLL.lua_istable(L, -1)) { LuaDLL.lua_pop(L, 1); return(1); } LuaDLL.lua_getfield(L, -1, "traceback"); if (LuaDLL.lua_isfunction(L, -1)) { LuaDLL.lua_pop(L, 2); return(1); } LuaDLL.lua_pushvalue(L, 1); /* pass error message */ LuaDLL.lua_pushinteger(L, 2); /* skip this function and traceback */ LuaDLL.lua_call(L, 2, 1); /* call debug.traceback */ return(1); }
public static int print(IntPtr L) { // For each argument we'll 'tostring' it int n = LuaDLL.lua_gettop(L); string s = String.Empty; //LuaDLL.lua_getglobal(L, "debug"); //LuaDLL.lua_getfield(L, -1, "traceback"); //LuaDLL.lua_pushvalue(L, 1); //LuaDLL.lua_pushnumber(L, 2); //LuaDLL.lua_call(L, 2, 1); //n = LuaDLL.lua_gettop(L); LuaDLL.lua_getglobal(L, "tostring"); for (int i = 1; i <= n; i++) { LuaDLL.lua_pushvalue(L, -1); /* function to be called */ LuaDLL.lua_pushvalue(L, i); /* value to print */ LuaDLL.lua_call(L, 1, 1); if (i > 1) { s += "\t"; } s += LuaDLL.lua_tostring(L, -1); LuaDLL.lua_pop(L, 1); /* pop result */ //LuaDLL.PrintCmd(s); } Debug.Log("LUA: " + s); return(0); }
public void LuaCall(int nArgs, int nResults) { LuaDLL.lua_call(L, nArgs, nResults); }
public static void lua_pushcsfunction(IntPtr luaState, LuaCSFunction function) { LuaDLL.lua_getref(luaState, SLua.LuaState.PCallCSFunctionRef); LuaDLL.lua_pushcclosure(luaState, Marshal.GetFunctionPointerForDelegate(function), 0); LuaDLL.lua_call(luaState, 1, 1); }