Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --{[1]="hello",[2]=32}
- function textutils.unserialize(s)
- length = string.len(s)
- t = {}
- for match in string.gmatch(s, "%b{}") do
- if match then
- --print(match)
- for match2 in string.gmatch(s, "%b[]=[^%,]+") do
- if match2 then
- --print(match2)
- _index = string.match(match2, "%b[]")
- if _index then
- index = string.match(_index, "[^%[%]]+")
- if index then
- if tonumber(index) then index = tonumber(index) else
- index = string.gsub(index, '"', "") end
- end
- end
- value = string.sub(string.match(match2, "=.+"), 2)
- --print("("..type(index)..") "..tostring(index)..": "..tostring(value))
- if value and index then
- t[index] = value
- end
- end
- end
- end
- end
- return t
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement