Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- "but to copy the code i got CC-Copy, wish works fine for normal code, but not for schematics.
- so i wrote a small program, to convert the schematic file into a table, searialize the table and safe the file local. Now i can copy the file with CC-Copy, on the Server i have the same converter running, to unsearilize the string, wish was given by CC-Copy and safe it as schematic file.
- pretty easy thing, for "just" playing around with turtles and schematics ;) but in bigger projects i love it ;)
- Usage:
- goto your local minecraft world, copy the schematic file into your turtle folder, copy the "convert" script in the same folder
- Run:
- convert toStringFile schematicFileName convertedFileName
- than Copy the convertedFile and the convert scropt with CC-Copy to the Server you are on and run:
- convert toByteFile convertedFileName newSchematicFileName
- as i said just usefull for ppl like me who are playing on a server without http and/or posibility to upload directly (like schematics)
- fileName: convert" ]]--
- local tArgs = { ... }
- function printUsage()
- print("Usage: convert toByteFile <Input file name> <Output file>")
- print("Usage: convert toStringFile <gunzipped schematic file | Input file name> <Output file>")
- end
- function convertToStringFile(inputFileName, outputFileName)
- if not fs.exists(inputFileName) then
- print("InputFile: " .. inputFileName .. " does not exist.")
- printUsage()
- return
- end
- if fs.exists(outputFileName) then
- print("OutputFile: " .. outputFileName .. " does exist, please delete it before or choose another filename.")
- printUsage()
- return
- end
- local inFile = fs.open(inputFileName, "rb")
- local byteArray = {}
- local byte = 0
- while byte ~= nil do
- byte = inFile.read()
- table.insert(byteArray, byte)
- end
- outFile = fs.open(outputFileName, "w")
- outFile.write(textutils.serialize(byteArray))
- outFile.close()
- end
- function convertToByteFile(inputFileName, outputFileName)
- if not fs.exists(inputFileName) then
- print("InputFile: " .. inputFileName .. " does not exist.")
- printUsage()
- return
- end
- if fs.exists(outputFileName) then
- print("OutputFile: " .. outputFileName .. " does exist, please delete it before or choose another filename.")
- printUsage()
- return
- end
- local inFile = fs.open(inputFileName, "r")
- local charArray = {}
- charArray = textutils.unserialize(inFile.readAll())
- inFile.close()
- local outFile = fs.open(outputFileName, "wb")
- for _, byte in ipairs(charArray) do
- outFile.write(byte)
- end
- outFile.close()
- end
- function main()
- if #tArgs ~= 3 then
- printUsage()
- return
- end
- if tArgs[2] == tArgs[3] then
- print("inputFileName and outputFileName are the same, please correct that")
- printUsage()
- return
- end
- if tArgs[1] == "toByteFile" then
- convertToByteFile(tArgs[2], tArgs[3])
- elseif tArgs[1] == "toStringFile" then
- convertToStringFile(tArgs[2], tArgs[3])
- else
- printUsage()
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement