SHARE
TWEET

Untitled

a guest Dec 9th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dofile("ccLIB")
  2.  
  3. function round(num,idp)
  4.  local mult = 10^(idp or 0)
  5.  return math.floor(num * mult + 0.5) / mult
  6. end
  7. clear()
  8. printC("Circle")
  9. nl()
  10. nl()
  11. write("Radius: ")
  12. rinput = read()
  13. radius = tonumber(rinput)
  14.  
  15.  
  16. _max = radius*2+1
  17. plot = {}
  18. for i=1,_max do
  19.     plot[i] = {}
  20.     for j=1,_max do
  21.         plot[i][j] = 0
  22.     end
  23. end
  24.  
  25. angle = 0
  26. step = 64
  27. --print(_max)
  28. --getKey()
  29.  
  30. while angle <= 2 * math.pi do
  31.     x_cord = round(math.sin(angle)*radius+radius,0)
  32.     y_cord = round(math.cos(angle)*radius+radius,0)
  33.     plot[x_cord+1][y_cord+1] = 1
  34.  --print("("..x_cord..","..y_cord..")")
  35.  --getKey()
  36.     angle = angle + (math.pi / step)
  37. end
  38.  
  39. turtle.turnRight()
  40. turtleBack(radius)
  41. turtle.turnLeft()
  42. turtleBack(radius)
  43.  
  44. for c=1,_max do
  45.     for i=1,_max do
  46.         if plot[c][i] == 1 then
  47.         turtle.placeDown()
  48.         end
  49.         turtleForward()
  50.     end
  51.     turtle.turnRight()
  52.     turtleForward()
  53.     turtle.turnLeft()
  54.     turtleBack(_max)
  55. 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
 
Top