Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function convertTableToNBT(t)
- local function tableToNBT(t)
- local function rll(s) return string.sub(tableToNBT(s),1,-2) end
- local nbt = ""
- for k,v in pairs(t) do
- if(type(v)~="table")then
- if(t[1]==nil)then
- if(type(v)~="string")then nbt = nbt..k..":"..v..","
- else nbt = nbt..k..":\""..v.."\"," end
- else
- if(type(v)~="string")then nbt = nbt..v..","
- else nbt = nbt..v.."," end
- end
- elseif(type(v)=="table")then
- if(v[1]~=nil)then nbt = nbt..k..":["..rll(v).."],"
- else
- if(type(k)~="number")then nbt = nbt..k..":{"..rll(v).."},"
- else nbt = nbt.."{"..rll(v).."}," end
- end end end
- return nbt
- end
- return "{"..string.sub(tableToNBT(t),1,-2).."}"
- end
Advertisement
Add Comment
Please, Sign In to add comment