Advertisement
Guest User

fromDisk.lua

a guest
Jul 9th, 2016
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. os.loadAPI("rotutil")
  2. local mX,mY,mZ=commands.getBlockPosition()
  3. local r=rotutil.opposite[rotutil.fromMeta(commands.getBlockInfo(mX,mY,mZ).metadata)]
  4. mX,mY,mZ=rotutil.addDir(r,mX,mY,mZ)
  5. local size = fs.open("disk/.dat/size","r")
  6. local MX,MY,MZ=tonumber(size.readLine()),tonumber(size.readLine()),tonumber(size.readLine())
  7. size.close()
  8. size=nil
  9. MX,MY,MZ=rotutil.bound(r,mX,mY,mZ,MX,MY,MZ)
  10. if mX>MX then mX,MX=MX,mX end
  11. if mY>MY then mY,MY=MY,mY end
  12. if mZ>MZ then mZ,MZ=MZ,mZ end
  13. local ids={}
  14. local nId=0
  15. local idsF=fs.open("disk/.dat/ids","r")
  16. local name=idsF.readLine()
  17. while  name do
  18.   ids[nId]=name
  19.   nId=nId+1
  20.   name=idsF.readLine()
  21. end
  22. local hasManyIds
  23. if nId>256 then hasManyIds=true end
  24. idsF.close()
  25. idsF=nil
  26. local idPack=fs.open("disk/.dat/idPack","rb")
  27. local meta=fs.open("disk/.dat/meta","rb")
  28. local function readBlock()
  29.   local id=idPack.read()
  30.   if hasManyIds then id=id+256*idPack.read() end
  31.   return ids[id],meta.read()
  32. end
  33. for y=mY,MY do
  34.   for z=mZ,MZ do
  35.     for x=mX,MX do
  36.       commands.async.setblock(x,y,z,readBlock())
  37.     end
  38.   end
  39. end
  40. idPack.close()
  41. meta.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement