SHARE
TWEET

Untitled

a guest Jun 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. radius =tonumber(read())
  2. x = -1
  3. y = 0
  4.  
  5. function round(x)
  6.  n = x % 1
  7.  
  8.  if n >= 0.5 then
  9.   return math.ceil(x)
  10.  else
  11.   return math.floor(x)
  12.  end
  13. end
  14.  
  15. function getQuaterSector(r)
  16.  sectorEdges = {}
  17.  
  18.   while x < r^2 do
  19.    x = x + 1
  20.    y =math.sqrt(r^2 - x)
  21.    
  22.    if math.sqrt(x) % 1 == 0 then
  23.     table.insert(sectorEdges,{math.sqrt(x),round(y)})
  24.    end
  25.    
  26.   end
  27.  
  28.  return sectorEdges
  29. end
  30.  
  31. function moveToOnYPlane(x1,z1,x2,z2)
  32.  
  33.  XDiff=x2-x1
  34.  if XDiff>0 then
  35.   turtle.turnRight()
  36.  elseif XDiff<0 then
  37.   turtle.turnLeft()
  38.  end
  39.  
  40.  if XDiff<0 then XDiff = -XDiff end
  41.   i=0
  42.  
  43.   while i<XDiff do
  44.    turtle.placeDown()
  45.    turtle.forward()
  46.    i=i+1
  47.   end
  48.  
  49.  if XDiff>0 then
  50.   turtle.turnLeft()
  51.  elseif XDiff<0 then
  52.   turtle.turnRight()
  53.  end
  54.  
  55.  ZDiff =z2-z1
  56.  if ZDiff<0 then
  57.   turtle.turnLeft()
  58.   turtle.turnLeft()
  59.  end
  60.  
  61.  if ZDiff <0 then ZDiff = -ZDiff end
  62.  
  63.  b=0
  64.  while b<math.abs(ZDiff) do
  65.   turtle.placeDown()
  66.   turtle.forward()
  67.   b = b+1
  68.  end
  69.  
  70.  if ZDiff<0 then
  71.   turtle.turnLeft()
  72.   turtle.turnLeft()
  73.  end
  74.  
  75. end
  76.  
  77. --[[
  78. This next block isn't working
  79. >get this to take the array and
  80. >print the quarter sector, placing below
  81. >then turn and repeat *3 times
  82. >move up a layer and reduce radius
  83. >repeat process and bam a sphere
  84. --]]
  85.  
  86. arr = getQuaterSector(radius)
  87.  
  88. a=1
  89. currentX=0
  90. currentZ=0
  91. moveToOnYPlane(0,0,currentX,currentZ)
  92. while a < table.getn(arr) do
  93.  moveToOnYPlane(currentX,currentZ,arr[a][1],arr[a][2])
  94. --  currentX=arr[a][1]
  95. --  currentZ=arr[a][2]
  96. moveToOnYPlane(currentX,currentZ,0,0)
  97.  a = a + 1
  98. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top