string/table扩展模块新增几个方法用于数据打包/解包

This commit is contained in:
MrZ626
2021-06-06 17:29:57 +08:00
parent f9ed93641c
commit 628365cb49
4 changed files with 89 additions and 30 deletions

View File

@@ -1,15 +1,7 @@
local scene={}
local function dumpCB(T)
love.system.setClipboardText(
love.data.encode(
'string','base64',
love.data.compress(
'string','zlib',
TABLE.dump(T)
)
)
)
love.system.setClipboardText(STRING.packText(TABLE.dump(T)))
LOG.print(text.exportSuccess,'message')
end
local function parseCB()
@@ -17,10 +9,8 @@ local function parseCB()
local s=love.system.getClipboardText()
--Decode
_,s=pcall(love.data.decode,'string','base64',s)
if not _ then LOG.print(text.dataCorrupted,'error')return end
_,s=pcall(love.data.decompress,'string','zlib',s)
if not _ then LOG.print(text.dataCorrupted,'error')return end
s=STRING.unpackText(s)
if not s then LOG.print(text.dataCorrupted,'error')return end
s=loadstring(s)
if s then