[READ-ONLY] Mirror of https://github.com/thoda-dev/DualUniverse. DualUniverse scripts
0

Configure Feed

Select the types of activity you want to include in your feed.

removed test data and add link

Thomas (Aug 2, 2023, 5:25 PM +0200) 7e6f1cb5 b777ec76

+11 -28
+6 -28
Serializer/Serializer.lua
··· 1 + --[[ 2 + Lua Serializer by Jericho 3 + Version: 1.0.0 4 + Source available at: https://github.com/Jericho1060/DualUniverse/blob/master/Serializer/Serializer.lua 5 + ]] 1 6 Serializer = { 2 7 __index = { 3 8 stringify = function(self, data) ··· 47 52 return count 48 53 end 49 54 } 50 - } 51 - 52 - local s = setmetatable({}, Serializer) 53 - local test = { "aaa", a="bbb", b="cccc"} 54 - print(s:tableLength(test)) 55 - 56 - local element = {'hello "-" world', 1234, 1234.5678, { "aaa", a="bbb"}} 57 - 58 - local str = s:stringify(element) 59 - 60 - print(str) 61 - 62 - local obj = s:parse(str) 63 - 64 - 65 - dumpTable = function (t, prefix) 66 - if prefix == nil then prefix = "" end 67 - for k, v in pairs(t) do 68 - if type(v) == 'table' then 69 - print(k .. ' is a table') 70 - dumpTable(v, '\t') 71 - else 72 - print(prefix .. k ..' = ' .. v) 73 - end 74 - end 75 - end 76 - 77 - dumpTable(obj) 55 + }
+5
Serializer/Serializer.min.lua
··· 1 + --[[ 2 + Lua Serializer by Jericho 3 + Version: 1.0.0 4 + Source available at: https://github.com/Jericho1060/DualUniverse/blob/master/Serializer/Serializer.lua 5 + ]] 1 6 Serializer={__index={stringify=function(self,a)if type(a)=='number'then return self:stringifyNumber(a)elseif type(a)=='string'then return self:stringifyString(a)elseif type(a)=='table'then return self:stringifyTable(a)elseif type(a)=='boolean'then return self:stringifyBoolean(a)end;return nil end,parse=function(self,b)return load("return "..b)()end,stringifyTableKey=function(self,c)if type(c)=='number'then return'['..self:stringifyNumber(c)..']'end;return c end,stringifyNumber=function(self,d)return tostring(d)end,stringifyString=function(self,b)return string.format('%q',b):gsub('\\\n','\n'):gsub('\\\r','\r'):gsub('\\\t','\t')end,stringifyTable=function(self,e)local b='{'local f=1;local g=self:tableLength(e)for h,i in pairs(e)do b=b..self:stringifyTableKey(h)..'='..self:stringify(i)if f<g then b=b..','end;f=f+1 end;return b..'}'end,stringifyBoolean=function(self,j)return tostring(j)end,tableLength=function(self,e)local k=0;for l in pairs(e)do k=k+1 end;return k end}}