Advertisement
antonsavov

Untitled

Jan 30th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. -- use this to copy a finished buildzone A (MASTER) to a target buildzone B (TARGET)
  2. -- it takes any coordinate in A and B as input
  3. -- the copying automatically takes the current grid setup for the PHV which is in the variable FIRST_ZONE
  4. -- MAKE SURE the coordinates match the coordinates form the main game script before running this one
  5. -- the script clones with "replace" flag so it overwrites everything in the target location
  6. -- the cloning clones everything from the ground (y=55) to the sky (y=255)
  7.  
  8.  
  9. 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
  10.  
  11. FIRSTZONE= {
  12. x=11685,
  13. y=57,
  14. z=-1869
  15. }
  16.  
  17. POINT_IN_MASTER_GAMETILE={
  18. x=11701,
  19. z=-1955
  20. }
  21.  
  22. POINT_IN_TARGET_GAMETILE={
  23. x=12172,
  24. z=-1769
  25. }
  26.  
  27. -- the CreateCloningParams function takes in a point in the buildzone A and a point in the buildzone B as parameters
  28. -- 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)
  29. -- the minecraft clone command has a limitation of 32768 blocks (enough for the equivalent of eight chunk sections)
  30. -- therefore a list of multiple clone commands is generated if the volume of the gametile is bigger
  31. function CreateCloningParams(pA, pB)
  32. local gt = {} -- the variable to hold the clone coordinates data for all layers of the buildzone. Like a cake :)
  33.  
  34.  
  35. local layerHeight = math.floor(32768/(BUILDZONE_WIDTH*BUILDZONE_WIDTH))+1
  36. --print(layerHeight)
  37. local counter = 1
  38. for y = 55, 254, layerHeight do
  39. 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
  40. gtLayer.x1 = math.floor((pA.x-FIRSTZONE.x)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.x
  41. --print(gtLayer.x1)
  42. gtLayer.y1 = y
  43. --print(gtLayer.y1)
  44. gtLayer.z1 = math.floor((pA.z-FIRSTZONE.z)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.z
  45. --print(gtLayer.z1)
  46. gtLayer.x2 = gtLayer.x1 + BUILDZONE_WIDTH
  47. --print(gtLayer.x2)
  48. gtLayer.y2 = y+layerHeight-1
  49. --print(gtLayer.y2)
  50. gtLayer.z2 = gtLayer.z1 + BUILDZONE_WIDTH
  51. --print(gtLayer.z2)
  52. gtLayer.x = math.floor((pB.x-FIRSTZONE.x)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.x
  53. gtLayer.y = y
  54. gtLayer.z = math.floor((pB.z-FIRSTZONE.z)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.z
  55. --add to the clone params array
  56. gt[counter] = gtLayer
  57. counter = counter + 1
  58. end
  59. return gt
  60. end
  61.  
  62. -- the CloneBuildZone function takes in a point in the buildzone A and a point in the buildzone B as parameters
  63. function CloneBuildZone(pA, pB)
  64. commands.say("cloning zone")
  65. local cp = CreateCloningParams(pA, pB)
  66. for i,layer in ipairs(cp) do
  67. print("cloning layer at: "..layer.x1..", "..layer.y1..", "..layer.z1..", "..layer.x2..", "..layer.y2..", "..layer.z2..", "..layer.x..", ".. layer.y..", "..layer.z)
  68. commands.clone(layer.x1,layer.y1,layer.z1,layer.x2,layer.y2,layer.z2,layer.x,layer.y,layer.z,"replace")
  69. end
  70. commands.say("zone cloned")
  71. end
  72.  
  73. CloneBuildZone(POINT_IN_MASTER_GAMETILE,POINT_IN_TARGET_GAMETILE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement