Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Circular Digger--
- function define()
- print("Circle Diameter: ")
- d = read()
- if d <= 1 then
- print("ERROR: Diameter must be greater than 1")
- end
- r = tonumber(d / 2 )-- radius
- print("Radius: " ..r)
- theta = 0
- r = r - 1 -- normalise values, otherwise r = 1 is actually r = 2
- m = peripheral.wrap("<SIDE>") -- allows interaction with the monitor
- currX = 0 -- Turtle's pos in the X (length)
- currY = 0 -- Turtle's pos in the Y (depth)
- currZ = 0 -- pos in the Z (width)
- end
- function getCoords()
- repeat
- for theta = 0, 359 do --draw all of the circle. (No 360 b/c 0 = 360)
- xCoord = math.floor(r * math.cos(math.rad(theta))) -- math.rad() math.cos/sin expects radians
- yCoord = math.floor(r * math.sin(math.rad(theta)))
- --m.setCursorPos(xCoord, yCoord) -- Monitor O utput
- --m.write("#") -- Replace with whatever the circle will be drawn as
- moveTo()
- end
- r = r - 1 -- reduce r by 1 and draw the circle again. draws the next 'inner' circle. Basically, this fills the entire circle in.
- until r == -1 -- technically -1 = 0, 0 = 1 etc. so really, until r = 0
- end
- function moveTo() -- TO DO: Turtle intergration
- atLoc = false
- repeat
- if currX > xCoord then
- turtle.back()
- currX = currX - 1
- end
- if currX < xCoord then
- turtle.forward()
- currX = currX + 1
- end
- if currX == xCoord then
- turtle.left()
- if currY > yCoord then
- turtle.back()
- currY = currY - 1
- end
- if currY < yCoord then
- turtle.forward()
- currY = currY + 1
- end
- if currY == yCoord then
- print("Made it!")
- atLoc = true
- end
- until atLoc == true
- end
- define()
- getCoords()
Advertisement
Add Comment
Please, Sign In to add comment