Advertisement
NAPTlME

--Circle for GPS host

May 29th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.56 KB | None | 0 0
  1. --Circle for GPS controller
  2. --NAPTlME
  3.  diameter,input = {...}
  4. circle = {4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,
  5.           42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,
  6.           77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96}
  7. circle[4] = {2}
  8. circle[5] = {3}
  9. circle[6] = {4}
  10. circle[7] = {3,2}
  11. circle[8] = {4,2}
  12. circle[9] = {5,2}
  13. circle[10] = {4,3,1}
  14. circle[11] = {5,2,2}
  15. circle[12] = {4,3,2,1}
  16. circle[13] = {5,3,2,1}
  17. circle[14] = {6,2,2,2}
  18. circle[15] = {5,3,2,2,1}
  19. circle[16] = {6,3,2,2,1}
  20. circle[17] = {5,3,3,1,2,1}
  21. circle[18] = {6,3,2,2,2,1}
  22. circle[19] = {7,3,2,2,2,1}
  23. circle[20] = {6,3,3,2,1,2,1}
  24. circle[21] = {7,3,2,2,2,2,1}
  25. circle[22] = {6,4,2,2,2,2,1,1}
  26. circle[23] = {7,3,3,2,2,1,2,1}
  27. circle[24] = {6,4,2,2,2,2,2,1,1}
  28. circle[25] = {7,3,3,2,2,2,1,2,1}
  29. circle[26] = {8,3,3,2,2,2,1,2,1}
  30. circle[27] = {7,4,2,3,2,1,2,2,1,1}
  31. circle[28] = {8,3,3,2,2,2,2,1,2,1}
  32. circle[29] = {7,4,3,2,2,2,2,1,2,1,1}
  33. circle[30] = {8,4,2,3,2,2,1,2,2,1,1}
  34. circle[31] = {7,4,3,2,2,2,2,2,1,2,1,1}
  35. circle[32] = {8,4,3,2,2,2,2,2,1,2,1,1}
  36. circle[33] = {9,3,3,3,2,2,2,1,2,1,2,1}
  37. circle[34] = {8,4,3,2,3,2,1,2,2,1,2,1,1}
  38. circle[35] = {9,4,3,2,2,2,2,2,2,1,2,1,1}
  39. circle[36] = {8,4,3,3,2,2,2,2,1,2,1,2,1,1}
  40. circle[37] = {9,4,3,3,2,2,2,2,2,1,2,1,2,1,1}
  41. circle[38] = {8,4,3,3,2,2,2,2,2,1,2,1,2,1,1}
  42. circle[39] = {9,4,3,3,2,2,2,2,2,1,2,1,2,1,1}
  43. circle[40] = {8,5,3,2,3,2,2,2,1,2,2,1,2,1,1,1}
  44. circle[41] = {9,4,3,3,2,2,2,2,2,2,1,2,1,2,1,1}
  45. circle[42] = {10,4,3,3,2,2,2,2,2,2,1,2,1,2,1,1}
  46. circle[43] = {9,4,4,2,3,2,2,2,2,1,2,2,1,1,2,1,1}
  47. circle[44] = {10,4,3,3,2,3,2,2,1,2,2,1,2,1,2,1,1}
  48. circle[45] = {9,5,3,3,2,2,2,2,2,2,2,1,2,1,2,1,1,1}
  49. circle[46] = {10,4,3,3,3,2,2,2,2,2,1,2,1,2,1,2,1,1}
  50. circle[47] = {9,5,3,3,2,3,2,2,2,1,2,2,1,2,1,2,1,1,1}
  51. circle[48] = {10,4,4,2,3,2,2,2,2,2,2,1,2,2,1,1,2,1,1}
  52. circle[49] = {9,5,3,3,3,2,2,2,2,2,2,1,2,1,2,1,2,1,1,1}
  53. circle[50] = {10,5,3,3,2,3,2,2,2,2,1,2,2,1,2,1,2,1,1,1}
  54. circle[51] = {11,4,4,2,3,2,3,2,2,1,2,2,1,2,2,1,1,2,1,1}
  55. circle[52] = {10,5,3,3,3,2,2,2,2,2,2,2,1,2,1,2,1,2,1,1,1}
  56. circle[53] = {11,4,4,3,2,3,2,2,2,2,2,1,2,2,1,2,1,1,2,1,1}
  57. circle[54] = {10,5,3,3,3,2,3,2,2,2,1,2,2,1,2,1,2,1,2,1,1,1}
  58. circle[55] = {11,4,4,3,3,2,2,2,2,2,2,2,2,1,2,1,2,1,1,2,1,1}
  59. circle[56] = {10,5,4,3,2,3,2,2,2,2,2,2,1,2,2,1,2,1,1,2,1,1,1}
  60. circle[57] = {11,5,3,3,3,2,3,2,2,2,2,1,2,2,1,2,1,2,1,2,1,1,1}
  61. circle[58] = {10,5,4,3,3,2,2,2,3,1,2,2,2,2,1,2,1,2,1,1,2,1,1,1}
  62. circle[59] = {11,5,3,3,3,3,2,2,2,2,2,2,2,1,2,1,2,1,2,1,2,1,1,1}
  63. circle[60] = {10,5,4,3,3,2,3,2,2,2,2,2,1,2,2,1,2,1,2,1,1,2,1,1,1}
  64. circle[61] = {11,5,4,3,2,3,2,3,2,2,2,1,2,2,1,2,2,1,2,1,1,2,1,1,1}
  65. circle[62] = {12,5,3,3,3,3,2,2,2,2,2,2,2,2,1,2,1,2,1,2,1,2,1,1,1}
  66. circle[63] = {11,5,4,3,3,2,3,2,2,2,2,2,2,1,2,2,1,2,1,2,1,1,2,1,1,1}
  67. circle[64] = {12,5,3,4,2,3,2,3,2,2,2,2,1,2,2,1,2,2,1,1,2,1,2,1,1,1}
  68. circle[65] = {11,5,4,3,3,3,2,2,2,2,2,2,2,2,2,1,2,1,2,1,2,1,1,2,1,1,1}
  69. circle[66] = {12,5,4,3,3,2,3,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,1,2,1,1,1}
  70. circle[67] = {11,5,4,3,3,3,2,3,2,2,2,2,2,1,2,2,1,2,1,2,1,2,1,1,2,1,1,1}
  71. circle[68] = {12,5,4,3,3,3,2,2,2,3,2,1,2,2,2,2,1,2,1,2,1,2,1,1,2,1,1,1}
  72. circle[69] = {11,6,3,4,3,2,3,2,2,2,2,2,2,2,2,1,2,2,1,2,1,1,2,1,2,1,1,1,1}
  73. circle[70] = {12,5,4,3,3,3,2,3,2,2,2,2,2,2,1,2,2,1,2,1,2,1,2,1,1,2,1,1,1}
  74. circle[71] = {11,6,4,3,3,2,3,2,3,2,2,2,2,1,2,2,1,2,2,1,2,1,2,1,1,2,1,1,1,1}
  75. circle[72] = {12,5,4,3,3,3,3,2,2,2,2,2,2,2,2,2,1,2,1,2,1,2,1,2,1,1,2,1,1,1}
  76. circle[73] = {13,5,4,3,3,3,2,3,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,2,1,1,2,1,1,1}
  77. circle[74] = {12,5,4,4,3,2,3,2,3,2,2,2,2,2,1,2,2,1,2,2,1,2,1,1,2,1,1,2,1,1,1}
  78. circle[75] = {13,5,4,3,3,3,3,2,2,2,3,2,1,2,2,2,2,1,2,1,2,1,2,1,2,1,1,2,1,1,1}
  79. circle[76] = {12,6,4,3,3,3,2,3,2,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,2,1,1,2,1,1,1,1}
  80. circle[77] = {13,5,4,4,3,2,3,2,3,2,2,2,2,2,2,1,2,2,1,2,2,1,2,1,1,2,1,1,2,1,1,1}
  81. circle[78] = {12,6,4,3,3,3,3,2,2,3,2,2,2,2,1,2,2,1,2,1,2,1,2,1,2,1,1,2,1,1,1,1}
  82. circle[79] = {13,5,4,4,3,3,2,3,2,2,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,1,2,1,1,2,1,1,1}
  83. circle[80] = {12,6,4,3,3,3,3,2,3,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,2,1,2,1,1,2,1,1,1,1}
  84. circle[81] = {13,5,5,3,3,3,3,2,2,3,2,2,2,2,2,1,2,2,2,1,2,1,2,1,2,1,2,1,1,1,2,1,1,1}
  85. circle[82] = {12,6,4,4,3,3,2,3,2,2,2,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,1,2,1,1,2,1,1,1,1}
  86. circle[83] = {13,6,4,3,3,3,3,2,3,2,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,2,1,2,1,1,2,1,1,1,1}
  87. circle[84] = {12,6,4,4,3,3,2,3,2,3,2,2,2,2,2,2,1,2,2,1,2,2,1,2,1,2,1,1,2,1,1,2,1,1,1,1}
  88. circle[85] = {13,6,4,3,4,2,3,3,2,2,2,3,2,2,1,2,2,2,2,1,2,1,2,2,1,1,2,1,2,1,1,2,1,1,1,1}
  89. circle[86] = {14,5,4,4,3,3,3,2,3,2,2,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,2,1,1,2,1,1,2,1,1,1}
  90. circle[87] = {13,6,4,4,3,3,2,3,2,3,2,2,2,2,2,2,2,1,2,2,1,2,2,1,2,1,2,1,1,2,1,1,2,1,1,1,1}
  91. circle[88] = {14,5,5,3,3,3,3,3,2,2,3,2,2,2,2,2,1,2,2,2,1,2,1,2,1,2,1,2,1,2,1,1,1,2,1,1,1}
  92. circle[89] = {13,6,4,4,3,3,3,2,3,2,2,2,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,2,1,1,2,1,1,2,1,1,1,1}
  93. circle[90] = {14,6,4,3,4,3,2,3,2,3,2,2,2,2,2,2,2,2,1,2,2,1,2,2,1,2,1,1,2,1,2,1,1,2,1,1,1,1}
  94. circle[91] = {13,6,4,4,3,3,3,3,2,2,3,2,2,2,2,2,2,1,2,2,2,1,2,1,2,1,2,1,2,1,1,2,1,1,2,1,1,1,1}
  95. circle[92] = {14,6,4,4,3,3,3,2,3,2,2,2,3,2,2,1,2,2,2,2,1,2,2,1,2,1,2,1,2,1,1,2,1,1,2,1,1,1,1}
  96. circle[93] = {13,6,5,3,3,3,3,3,2,3,2,2,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,2,1,2,1,2,1,1,1,2,1,1,1,1}
  97. circle[94] = {14,6,4,4,3,3,3,2,3,2,3,2,2,2,2,2,2,2,1,2,2,1,2,2,1,2,1,2,1,2,1,1,2,1,1,2,1,1,1,1}
  98. circle[95] = {13,6,5,3,4,3,2,3,3,2,2,2,3,2,2,2,1,2,2,2,2,1,2,1,2,2,1,2,1,1,2,1,2,1,1,1,2,1,1,1,1}
  99. circle[96] = {14,6,4,4,3,3,3,3,2,3,2,2,2,2,2,2,2,2,2,2,1,2,2,1,2,1,2,1,2,1,2,1,1,2,1,1,2,1,1,1,1}
  100.  
  101. function invTotal()
  102.   inv = 0
  103.   for i = 1,16 do
  104.     indInv = turtle.getItemCount(i)
  105.     inv = inv+indInv
  106.   end
  107.   local total = 1
  108.   for k = 1,#circle[diameter] do
  109.     total = total+circle[diameter][k]
  110.   end
  111.   maximum = math.floor(inv/total)
  112. end
  113.  
  114.  
  115. function isOdd(n)
  116.   if n%2==1 then
  117.     return true
  118.   else
  119.     return false
  120.   end
  121. end
  122.  
  123.  
  124. function up()
  125.   while not turtle.up() do
  126.     turtle.digUp()
  127.   end
  128. end
  129.  
  130. function forward(num)
  131.   for i = 1,num do
  132.     while not turtle.forward() do
  133.       turtle.dig()
  134.       turtle.attack()
  135.     end
  136.   end
  137. end
  138.  
  139. function placeDown()
  140.   for j = 1,16 do
  141.     turtle.select(j)
  142.     if turtle.compareTo(16) then
  143.       break
  144.     end
  145.   end
  146.   turtle.digDown()
  147.   turtle.placeDown()
  148. end
  149.  
  150. function placeMove(num)
  151.   for k = 1,num do
  152.     placeDown()
  153.     if k ~= num then
  154.       forward(1)
  155.     end
  156.   end
  157.   turtle.turnRight()
  158.   forward(1)
  159.   turtle.turnLeft()
  160. end
  161.  
  162. function cylinder(height)
  163.   for i = 1,tonumber(height) do
  164.      for j = 1,#circle[diameter] do
  165.        placeMove(circle[diameter][j])
  166.      end
  167.     placeDown()
  168.     forward(1)
  169.     turtle.turnRight()
  170.     up()
  171.   end
  172. end
  173.  
  174. function main()
  175.   radius = math.floor(diameter/2)
  176.   invTotal()
  177.   if maximum == 0 then
  178.     repeat
  179.       rednet.broadcast('empty')
  180.       read()
  181.       invTotal()
  182.     until maximum>0
  183.     rednet.broadcast('Ready')
  184.   end
  185.   id,msg = rednet.receive(5)
  186.   if msg then
  187.     repeat
  188.       id,msg = rednet.receive(3)
  189.     until msg = 'Ready'
  190.     id,msg = rednet.receive(5)
  191.   end
  192.   if diameter > 15 then
  193.     forward(radius-8)
  194.     turtle.turnRight()
  195.   else
  196.     turtle.turnRight()
  197.     turtle.turnRight()
  198.     forward(8-radius)
  199.     turtle.turnLeft()
  200.   end
  201.   forward(8-math.ceil(circle[diameter][1]/2))
  202.   cylinder(input)
  203.   turtle.turnLeft()
  204.   turtle.turnLeft()
  205.   forward(8-math.ceil(circle[diameter][1]/2))
  206.   if diameter>15 then
  207.     turtle.turnLeft()
  208.     forward(radius-8)
  209.     turtle.turnRight()
  210.     turtle.turnRight()
  211.   else
  212.     turtle.turnRight()
  213.     forward(8-radius)
  214.   end
  215. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement