Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p,o,s = 8,3,8
- function getFacing()
- directions = {"unknown","north","south","west","east"}
- blockInfo = commands.getBlockInfo(commands.getBlockPosition())
- print("My facing is ", directions[blockInfo.metadata],".")
- facing = directions[blockInfo.metadata]
- -- print(facing)
- end
- function setModifiers()
- fx,fz,swapxz = 0,0,false
- if facing == "west" then fx,fz,swapxz = 1,1,true
- elseif facing == "east" then fx,fz,swapxz = -1,-1,true
- elseif facing == "north" then fx,fz,swapxz = -1,1,false
- elseif facing == "south" then fx,fz,swapxz = 1,-1,false
- end
- end
- function relXYZ(x,y,z)
- cx,cy,cz = commands.getBlockPosition()
- -- print(cx+fx+(x*fx),",",cy+y,",",cz+fz+(z*fz))
- -- commands.setblock(cx+fx+(x*fx),cy+y,cz+fz+(z*fz),"minecraft:stone")
- return (cx+fx+(x*fx)), (cy+y), (cz+fz+(z*fz))
- end
- function saveBlock(x,y,z)
- -- print(textutils.serialize(blockData))
- data = commands.getBlockInfo(x,y,z)
- -- if not blockData[x] then blockData[x] = {} end
- -- if not blockData[x][y] then blockData[x][y] = {} end
- -- if not blockData[x][y][z] then blockData[x][y][z] = {} end
- -- blockData[x][y][z]["name"] = data["name"]
- -- blockData[x][y][z]["metadata"] = data["metadata"]
- blockData = {
- [x] = {
- [y] = {
- [z] = {
- name=data["name"],
- metadata=data["metadata"]
- } or {}
- } or {}
- } or {}
- }
- -- blockData = {[x]={[y]={[z]={name=data["name"],metadata=data["metadata"]}}}}
- -- print(textutils.serialize(blockData))
- end
- function writeBlocks()
- print("Saving to file...")
- file = io.open("blocks","w")
- file:write(textutils.serialize(blockData))
- file:close()
- print("Saving Complete!")
- textutils.pagedPrint(textutils.serialize(blockData))
- end
- function saveArea(x,y,z, x2,y2,z2)
- print("Saving Area, this may take a moment...")
- print(x,"x:",x2,"x2 ",y,"y:",y2,"y2 ",z,"z:",z2,"z2")
- xStart, yStart, zStart = relXYZ(x,y,z)
- xEnd, yEnd, zEnd = relXYZ(x2,y2,z2)
- print("Scanning Area...")
- blockData = {}
- for x = xStart, xEnd,fx do
- for y = yStart, yEnd do
- for z = zStart, zEnd, fz do
- saveBlock(x,y,z)
- end
- end
- end
- writeBlocks()
- end
- getFacing()
- setModifiers()
- --relXYZ(p,o,s)
- saveArea(0,3,0,8,3,8)
Advertisement
Add Comment
Please, Sign In to add comment