Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- radius =tonumber(read())
- x = -1
- y = 0
- function round(x)
- n = x % 1
- if n >= 0.5 then
- return math.ceil(x)
- else
- return math.floor(x)
- end
- end
- function getQuaterSector(r)
- sectorEdges = {}
- while x < r^2 do
- x = x + 1
- y =math.sqrt(r^2 - x)
- if math.sqrt(x) % 1 == 0 then
- table.insert(sectorEdges,{math.sqrt(x),round(y)})
- end
- end
- return sectorEdges
- end
- function moveToOnYPlane(x1,z1,x2,z2)
- XDiff=x2-x1
- if XDiff>0 then
- turtle.turnRight()
- elseif XDiff<0 then
- turtle.turnLeft()
- end
- if XDiff<0 then XDiff = -XDiff end
- i=0
- while i<XDiff do
- turtle.placeDown()
- turtle.forward()
- i=i+1
- end
- if XDiff>0 then
- turtle.turnLeft()
- elseif XDiff<0 then
- turtle.turnRight()
- end
- ZDiff =z2-z1
- if ZDiff<0 then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- if ZDiff <0 then ZDiff = -ZDiff end
- b=0
- while b<math.abs(ZDiff) do
- turtle.placeDown()
- turtle.forward()
- b = b+1
- end
- if ZDiff<0 then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- --[[
- This next block isn't working
- >get this to take the array and
- >print the quarter sector, placing below
- >then turn and repeat *3 times
- >move up a layer and reduce radius
- >repeat process and bam a sphere
- --]]
- arr = getQuaterSector(radius)
- a=1
- currentX=0
- currentZ=0
- moveToOnYPlane(0,0,currentX,currentZ)
- while a < table.getn(arr) do
- moveToOnYPlane(currentX,currentZ,arr[a][1],arr[a][2])
- -- currentX=arr[a][1]
- -- currentZ=arr[a][2]
- moveToOnYPlane(currentX,currentZ,0,0)
- a = a + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement