Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- clears the area on all sides around a Builzone so that is can be saved as screenshot for quick results preview
- -- it requires user to place a computer with this prgoram in the wanted buildzone
- -- coordinates are calculated based on cumpoert location and the PHV grid set in the main game script
- BUILDZONE_WIDTH = 62 -- the actual zone width is 63 blocks, but for some reason due to how minecraft handles relative coordinates this has to be 62
- FIRSTZONE= {
- x=11685,
- y=57,
- z=-1869
- }
- POINT_IN_BUILDZONE={
- x=11701,
- z=-1955
- }
- local ox,oy,oz = commands.getBlockPosition() -- get the position of the computer
- -- the CreateFillParams function takes in a point in the buildzone to be deleted (filled with air)
- -- it returns the coordinates needed for the minecraft fill command (start point x1,y1,z1 and end point x2,y2,z2)
- -- the minecraft fill command has a limitation of 32768 blocks (enough for the equivalent of eight chunk sections)
- -- therefore a list of multiple fill commands is generated if the volume of the buildzone is bigger
- function CreateFillParams(pointInBuildzone)
- local gt = {} -- the variable to hold the fill coordinates data for all layers of the buildzone. Like a cake :)
- local layerHeight = math.floor(32768/(BUILDZONE_WIDTH*BUILDZONE_WIDTH))
- --print(layerHeight)
- local counter = 1
- for y = 0, 254, layerHeight do
- local gtLayer = {} -- a variable to hold the fill variables for one layer of the buildzone, each layer is so tall so that Volume = buildzone_width^2*layerHeight < 32768
- gtLayer.x1 = math.floor((pointInBuildzone.x-FIRSTZONE.x)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.x
- --print(gtLayer.x1)
- gtLayer.y1 = y
- --print(gtLayer.y1)
- gtLayer.z1 = math.floor((pointInBuildzone.z-FIRSTZONE.z)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.z
- --print(gtLayer.z1)
- gtLayer.x2 = gtLayer.x1 + BUILDZONE_WIDTH
- --print(gtLayer.x2)
- gtLayer.y2 = y+layerHeight-1
- --print(gtLayer.y2)
- gtLayer.z2 = gtLayer.z1 + BUILDZONE_WIDTH
- --print(gtLayer.z2)
- --add to the fill params array
- gt[counter] = gtLayer
- counter = counter + 1
- end
- return gt
- end
- -- the CloneBuildZone function takes in a point in the buildzone A and a point in the buildzone B as parameters
- function CleanAroundBuildZone()
- commands.say("clearing around zone")
- local p = {
- x=ox+BUILDZONE_WIDTH,
- y=oy,
- z=oz
- }
- local cp = CreateFillParams(p)
- for i,layer in ipairs(cp) do
- print("filling layer at: "..layer.x1..", "..layer.y1..", "..layer.z1..", "..layer.x2..", "..layer.y2..", "..layer.z2..", "..layer.x..", ".. layer.y..", "..layer.z)
- commands.fill(layer.x1,layer.y1,layer.z1,layer.x2,layer.y2,layer.z2,"minecraft:air",0)
- end
- commands.say("area around the zone is cleared")
- end
- CleanAroundBuildZone()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement