Advertisement
antonsavov

Untitled

Feb 21st, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. -- clears the area on all sides around a Builzone so that is can be saved as screenshot for quick results preview
  2. -- it requires user to place a computer with this prgoram in the wanted buildzone
  3. -- coordinates are calculated based on cumpoert location and the PHV grid set in the main game script
  4.  
  5. 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
  6.  
  7. FIRSTZONE= {
  8. x=11685,
  9. y=57,
  10. z=-1869
  11. }
  12.  
  13.  
  14. POINT_IN_BUILDZONE={
  15. x=11701,
  16. z=-1955
  17. }
  18.  
  19. local ox,oy,oz = commands.getBlockPosition() -- get the position of the computer
  20.  
  21. -- the CreateFillParams function takes in a point in the buildzone to be deleted (filled with air)
  22. -- it returns the coordinates needed for the minecraft fill command (start point x1,y1,z1 and end point x2,y2,z2)
  23. -- the minecraft fill command has a limitation of 32768 blocks (enough for the equivalent of eight chunk sections)
  24. -- therefore a list of multiple fill commands is generated if the volume of the buildzone is bigger
  25. function CreateFillParams(pointInBuildzone, from, to)
  26. local gt = {} -- the variable to hold the fill coordinates data for all layers of the buildzone. Like a cake :)
  27.  
  28.  
  29. local layerHeight = math.floor(32768/(BUILDZONE_WIDTH*BUILDZONE_WIDTH))
  30. --print(layerHeight)
  31. local counter = 1
  32. for y = from, to, layerHeight do
  33. 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
  34. gtLayer.x1 = math.floor((pointInBuildzone.x-FIRSTZONE.x)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.x
  35. --print(gtLayer.x1)
  36. gtLayer.y1 = y
  37. --print(gtLayer.y1)
  38. gtLayer.z1 = math.floor((pointInBuildzone.z-FIRSTZONE.z)/(BUILDZONE_WIDTH+1))*(BUILDZONE_WIDTH+1)+FIRSTZONE.z
  39. --print(gtLayer.z1)
  40. gtLayer.x2 = gtLayer.x1 + BUILDZONE_WIDTH
  41. --print(gtLayer.x2)
  42. gtLayer.y2 = y+layerHeight-1
  43. --print(gtLayer.y2)
  44. gtLayer.z2 = gtLayer.z1 + BUILDZONE_WIDTH
  45. --print(gtLayer.z2)
  46. --add to the fill params array
  47. gt[counter] = gtLayer
  48. counter = counter + 1
  49. end
  50. return gt
  51. end
  52.  
  53. -- the CloneBuildZone function takes in a point in the buildzone A and a point in the buildzone B as parameters
  54. function CleanAroundBuildZone()
  55. commands.say("clearing around zone")
  56. for xi=-2,2 do
  57. for zi=-2,2 do
  58. local p = {
  59. x=ox+xi*BUILDZONE_WIDTH,
  60. y=oy,
  61. z=oz+zi*BUILDZONE_WIDTH
  62. }
  63. if (xi~=0 or zi~=0) then
  64. local cp = CreateFillParams(p,0,254)
  65. for i,layer in ipairs(cp) do
  66. print("filling layer at: "..layer.x1..", "..layer.y1..", "..layer.z1.." to "..layer.x2..", "..layer.y2..", "..layer.z2)
  67. commands.fill(layer.x1,layer.y1,layer.z1,layer.x2,layer.y2,layer.z2,"minecraft:air",0)
  68. end
  69. else
  70. local cp = CreateFillParams(p,0,47)
  71. for i,layer in ipairs(cp) do
  72. print("filling layer at: "..layer.x1..", "..layer.y1..", "..layer.z1.." to "..layer.x2..", "..layer.y2..", "..layer.z2)
  73. commands.fill(layer.x1,layer.y1,layer.z1,layer.x2,layer.y2,layer.z2,"minecraft:air",0)
  74. end
  75. end
  76. end
  77. end
  78. commands.say("area around the zone is cleared")
  79. end
  80.  
  81. CleanAroundBuildZone()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement