add lua log
parent
30ceef6fb2
commit
098024c896
|
@ -1,4 +1,6 @@
|
|||
package.path = package.path ..';luafight/?.lua';
|
||||
-- linux
|
||||
-- package.path = package.path ..';../luafight/?.lua';
|
||||
|
||||
require("Modules.Battle.Logic.Misc.BattleDefine")
|
||||
require("Modules.Battle.Logic.Misc.BattleUtil")
|
||||
|
@ -25,6 +27,37 @@ local Random = Random
|
|||
local _fightData
|
||||
local _optionData
|
||||
|
||||
local function pairsByKeys(t)
|
||||
local a = {}
|
||||
for n in pairs(t) do
|
||||
if n then
|
||||
a[#a+1] = n
|
||||
end
|
||||
end
|
||||
table.sort(a, function( op1, op2 )
|
||||
local type1, type2 = type(op1), type(op2)
|
||||
local num1, num2 = tonumber(op1), tonumber(op2)
|
||||
|
||||
if ( num1 ~= nil) and (num2 ~= nil) then
|
||||
return num1 < num2
|
||||
elseif type1 ~= type2 then
|
||||
return type1 < type2
|
||||
elseif type1 == "string" then
|
||||
return op1 < op2
|
||||
elseif type1 == "boolean" then
|
||||
return op1
|
||||
-- 以上处理: number, string, boolean
|
||||
else -- 处理剩下的: function, table, thread, userdata
|
||||
return tostring(op1) < tostring(op2) -- tostring后比较字符串
|
||||
end
|
||||
end)
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
return a[i], t[a[i]]
|
||||
end
|
||||
end
|
||||
|
||||
local function PrintTable(tb)
|
||||
local indent_str = "{"
|
||||
local count = 0
|
||||
|
@ -44,7 +77,7 @@ local function PrintTable(tb)
|
|||
end
|
||||
|
||||
local index = 0
|
||||
for k,v in pairs(tb) do
|
||||
for k,v in pairsByKeys(tb) do
|
||||
index = index + 1
|
||||
if type(k) ~= "number" then
|
||||
if type(v) == "table" then
|
||||
|
|
Loading…
Reference in New Issue