Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- use this to copy a finished buildzone A (MASTER) to a target buildzone B (TARGET)
- -- it takes any coordinate in A and B as input
- -- the copying automatically takes the current grid setup for the PHV which is in the variable FIRST_ZONE
- -- MAKE SURE the coordinates match the coordinates form the main game script before running this one
- -- the script clones with "replace" flag so it overwrites everything in the target location
- -- the cloning clones everything from the ground (y=55) to the sky (y=255)
- 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_MASTER_GAMETILE={
- x=11701,
- z=-1955
- }
- POINT_IN_TARGET_GAMETILE={
- x=12172,
- z=-1769
- }
- -- the CreateCloningParams function takes in a point in the buildzone A and a point in the buildzone B as parameters
- -- it returns the coordinates needed for the minecraft clone command (start point x1,y1,z1 and end point x2,y2,z2 of the master and start point x,y,z of the target)
- -- the minecraft clone command has a limitation of 32768 blocks (enough for the equivalent of eight chunk sections)
- -- therefore a list of multiple clone commands is generated if the volume of the gametile is bigger
- function CreateCloningParams(pA, pB)
- local gt = {} -- the variable to hold the clone coordinates data for all layers of the buildzone. Like a cake :)
- local layerHeight = math.floor(32768/(BUILDZONE_WIDTH*BUILDZONE_WIDTH))+1
- --print(layerHeight)
- local counter = 1
- for y = 55, 254, layerHeight do
- local gtLayer = {} -- a variable to hold the clone variables for one layer of the buildzone, each layer is so tall so that Volume = buildzone_width^2*layerHeight < 32768
- gtLayer.x1 = math.floor((pA.x-FIRSTZONE.x)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.x
- --print(gtLayer.x1)
- gtLayer.y1 = y
- --print(gtLayer.y1)
- gtLayer.z1 = math.floor((pA.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)
- gtLayer.x = math.floor((pB.x-FIRSTZONE.x)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.x
- gtLayer.y = y
- gtLayer.z = math.floor((pB.z-FIRSTZONE.z)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.z
- --add to the clone 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 CloneBuildZone(pA, pB)
- commands.say("cloning zone")
- local cp = CreateCloningParams(pA, pB)
- for i,layer in ipairs(cp) do
- print("cloning layer at: "..layer.x1..", "..layer.y1..", "..layer.z1..", "..layer.x2..", "..layer.y2..", "..layer.z2..", "..layer.x..", ".. layer.y..", "..layer.z)
- commands.clone(layer.x1,layer.y1,layer.z1,layer.x2,layer.y2,layer.z2,layer.x,layer.y,layer.z,"replace")
- end
- commands.say("zone cloned")
- end
- CloneBuildZone(POINT_IN_MASTER_GAMETILE,POINT_IN_TARGET_GAMETILE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement