Add files via upload

This commit is contained in:
CoCo ainrm-
2022-02-11 17:06:16 +08:00
committed by GitHub
commit f5f44f2e03
14 changed files with 558 additions and 0 deletions

73
tableXstring.lua Normal file
View File

@@ -0,0 +1,73 @@
function ToStringEx(value)
if type(value)=='table' then
return TableToStr(value)
elseif type(value)=='string' then
return "\'"..value.."\'"
else
return tostring(value)
end
end
function TableToStr(t)
if t == nil then return "" end
local retstr= "{"
local i = 1
for key,value in pairs(t) do
local signal = ","
if i==1 then
signal = ""
end
if key == i then
retstr = retstr..signal..ToStringEx(value)
else
if type(key)=='number' or type(key) == 'string' then
retstr = retstr..signal..'['..ToStringEx(key).."]="..ToStringEx(value)
else
if type(key)=='userdata' then
retstr = retstr..signal.."*s"..TableToStr(getmetatable(key)).."*e".."="..ToStringEx(value)
else
retstr = retstr..signal..key.."="..ToStringEx(value)
end
end
end
i = i+1
end
retstr = retstr.."}"
return retstr
end
function StrToTable(str)
if str == nil or type(str) ~= "string" then
return
end
return loadstring("return " .. str)()
end
function transTable(xxx)
local yyy = {}
for i=#xxx,1,-1 do
if #yyy ~= 0 then
yyy = xxx[i].."; "..yyy
else
yyy = xxx[i]
end
end
return yyy
end
function split( str,reps )
local resultStrList = {}
string.gsub(str,'[^'..reps..']+',function ( w )
table.insert(resultStrList,w)
end)
return resultStrList
end