SHOW:
|
|
- or go back to the newest paste.
| 1 | --upload to Market | |
| 2 | - | local tArgs = {...}
|
| 2 | + | tArgs = {...}
|
| 3 | shell.run("clr")
| |
| 4 | - | -- Usage: market upload [file] |
| 4 | + | |
| 5 | - | -- market (list schematics) |
| 5 | + | if #tArgs == 1 then |
| 6 | - | -- market [file] (download schematic) |
| 6 | + | print("Usage = market upload [file]")
|
| 7 | end | |
| 8 | - | function convertToStringFile(inputFileName, outputFileName) |
| 8 | + | |
| 9 | - | if not fs.exists(inputFileName) then |
| 9 | + | if not fs.exists("blueprints") then
|
| 10 | - | print("InputFile: " .. inputFileName .. " does not exist.")
|
| 10 | + | fs.makeDir("blueprints")
|
| 11 | - | printUsage() |
| 11 | + | |
| 12 | - | return |
| 12 | + | |
| 13 | - | end |
| 13 | + | --[[ |
| 14 | - | if fs.exists(outputFileName) then |
| 14 | + | if not fs.exists("convert") then
|
| 15 | - | print("OutputFile: " .. outputFileName .. " does exist, please delete it before or choose another filename.")
|
| 15 | + | shell.run("pastebin get NUspW9KB convert")
|
| 16 | - | printUsage() |
| 16 | + | |
| 17 | - | return |
| 17 | + | ]] |
| 18 | - | end |
| 18 | + | |
| 19 | - | |
| 19 | + | local files = {
|
| 20 | - | local inFile = fs.open(inputFileName, "rb") |
| 20 | + | |
| 21 | - | |
| 21 | + | |
| 22 | - | local byteArray = {}
|
| 22 | + | |
| 23 | - | local byte = 0 |
| 23 | + | |
| 24 | - | while byte ~= nil do |
| 24 | + | |
| 25 | - | byte = inFile.read() |
| 25 | + | |
| 26 | - | table.insert(byteArray, byte) |
| 26 | + | if tArgs[1] == "upload" then |
| 27 | - | end |
| 27 | + | |
| 28 | - | |
| 28 | + | |
| 29 | - | outFile = fs.open(outputFileName, "w") |
| 29 | + | |
| 30 | - | outFile.write(textutils.serialize(byteArray)) |
| 30 | + | -- shell.run("convert toStringFile "..tArgs[2].." sSchematic")
|
| 31 | - | outFile.close() |
| 31 | + | shell.run("pastebin put sSchematic")
|
| 32 | ||
| 33 | - | |
| 33 | + | |
| 34 | - | function convertToByteFile(inputFileName, outputFileName) |
| 34 | + | |
| 35 | - | |
| 35 | + | for i,v in pairs(files) do |
| 36 | - | if not fs.exists(inputFileName) then |
| 36 | + | local w = fs.open("blueprints/"..i,"w")
|
| 37 | - | print("InputFile: " .. inputFileName .. " does not exist.")
|
| 37 | + | w.write([[ |
| 38 | - | printUsage() |
| 38 | + | local schem = http.get("http://pastebin.com/raw/]]..v..[[").readAll()
|
| 39 | - | return |
| 39 | + | local h = fs.open("temp","w")
|
| 40 | - | end |
| 40 | + | h.write(schem) |
| 41 | - | if fs.exists(outputFileName) then |
| 41 | + | h.close() |
| 42 | - | print("OutputFile: " .. outputFileName .. " does exist, please delete it before or choose another filename.")
|
| 42 | + | shell.run("convert toByteFile temp ]]..i..[[")
|
| 43 | - | printUsage() |
| 43 | + | if fs.exists("temp") then
|
| 44 | - | return |
| 44 | + | fs.delete("temp")
|
| 45 | - | end |
| 45 | + | |
| 46 | - | |
| 46 | + | ]]) |
| 47 | - | local inFile = fs.open(inputFileName, "r") |
| 47 | + | w.close() |
| 48 | - | local charArray = {}
|
| 48 | + | |
| 49 | - | charArray = textutils.unserialize(inFile.readAll()) |
| 49 | + | |
| 50 | - | inFile.close() |
| 50 | + |