Advertisement
Asummonster

World copypaster [OpenComputers]

Jul 8th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. debug=require("component").debug.getWorld()
  2. serlib=require("serialization")
  3. ser=serlib.serialize
  4. unser=serlib.unserialize
  5. args={...}
  6. function scan(xstart, ystart, zstart, xstop, ystop, zstop)
  7.     tableTMP={}
  8.     for y=ystart, ystop do
  9.         for x=xstart, xstop do
  10.             for z=zstart, zstop do
  11.                 id=debug.getBlockId(x, y, z)
  12.                 if id~=0 then
  13.                     tmp={x-xstop, y-ystop, z-zstop, id, debug.getMetadata(x, y, z)}
  14.                     table.insert(tableTMP, tmp)
  15.                     print(x-xstop, y-ystop, z-zstop)
  16.                 end
  17.             end
  18.         end
  19.     end
  20.     return tableTMP
  21. end
  22. function saveFile()
  23.     file=io.open(args[8], "w")
  24.     file:write(ser(scan(args[2], args[3], args[4], args[5], args[6], args[7])))
  25.     file:flush()
  26.     file:close()
  27. end
  28. function place(filename, X, Y, Z)
  29.     home=unser(io.lines(filename)())
  30.     for i=1, #home do
  31.         x, y, z, id, meta = home[i][1]+X, home[i][2]+Y, home[i][3]+Z, home[i][4], home[i][5]
  32.         debug.setBlock(x, y, z, id, meta)
  33.         print(x, y, z, id)
  34.     end
  35. end
  36. if args[1]==nil then print("Использование: save <xstart> <ystart> <zstart> <xstop> <ystop> <zstop> <filename>\nplace <filename> <x> <y> <z>")
  37. elseif args[1]=="save" then saveFile()
  38. elseif args[1]=="place" then place(args[2], args[3], args[4], args[5])
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement