Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local filepaths = {}
- local data = {}
- function getData(a)
- local b = {}
- local c = a
- local d
- for e=1,#a do
- if e == a then
- error("A")
- end
- d = string.find(c, "\n")
- if d == nil then
- break
- end
- b[d] = string.sub(c,1,d-1)
- c = string.sub(c,d+2,#c)
- end
- return b
- end
- function pack(filepath)
- local file = fs.open(filepath, "r")
- filepaths[#filepaths+1] = filepath
- data[#data+1] = textutils.serialise(file.readAll())
- file.close()
- end
- function export(filepath)
- local file = fs.open(filepath, "w")
- file.write("local filepaths = {")
- for a,b in pairs(filepaths) do
- file.write('"'..b..'",')
- end
- file.writeLine("}")
- file.write("local data = {")
- for a,b in pairs(data) do
- local c = getData(b)
- for d=1,#c-1 do
- file.write(c[d])
- file.write("\\n")
- print(c[d])
- end
- file.write(c[#c])
- end
- file.writeLine("}")
- file.writeLine("local path = shell.dir()")
- for a,b in pairs(data) do
- file.writeLine("local file = fs.open(path..filepaths["..a.."], 'w')")
- file.writeLine("file.write(data["..a.."])")
- file.writeLine("file.close()")
- end
- file.close()
- end
- local t = {...}
- if #t<2 then
- print("Usage: czip <save path> <file1> <file2> ...")
- error()
- end
- for a=2,#t do
- pack(t[a])
- end
- export(t[1])
Advertisement
Add Comment
Please, Sign In to add comment