Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. --Equation Builder:
  2. --Printables:
  3.  
  4. io.write("Input equation, increment size, number of dimensions, parameters, limits first dimension (lower upper), limits second dimension (lower upper), limits third dimension (lower upper)")
  5. --Input equation: 1 for ellipse, 2 for parabola, 3 for etc
  6. --Parameters is table of form: {a,b,c,d,e}
  7. --Wireless Connection:
  8. --Not yes
  9.  
  10. --Variables:
  11. Args = {...}
  12.  
  13. --Parameters:
  14.  
  15. InputEquation = tonumber(Args[1])
  16. i = Args[2] --Incrementer
  17. dim = tonumber(Args[3])
  18.  
  19.  
  20. Zmax = tonumber(Args[10])
  21. Zmin = tonumber(Args[9])
  22. Z = {}
  23.  
  24. Xmax = tonumber(Args[6])
  25. Xmin = tonumber(Args[5])
  26. X = Xmin
  27.  
  28. if dim > 2 then
  29. Ymax = tonumber(Args[8])
  30. Ymin = tonumber(Args[7])
  31. Y = Zmin
  32. end
  33.  
  34. a = Args[11]
  35. b = Args[12]
  36. c = Args[13]
  37. d = Args[14]
  38. e = Args[15]
  39. locX = 0
  40. locZ = 0
  41.  
  42. --Functions:
  43.  
  44. function Eq()
  45. if InputEquation == 1 then
  46. if dim == 2 then
  47. EqZ = (b/a)*math.sqrt(a^2-X^2) --Rewriten Ellipse of form "x^2/a^2+y^2/b^2==1"
  48. elseif dim == 3 then
  49.  
  50. end
  51.  
  52. elseif InputEquation == 2 then
  53.  
  54. elseif InputEquation == 3 then
  55.  
  56. end
  57. end
  58.  
  59. --Refuels turtle
  60. function TurtleRefuel() --Refuel
  61. if turtle.getFuelLevel() < 320 and turtle.getItemCount(1) > 3 then
  62. turtle.select(1)
  63. turtle.refuel(3)
  64. print("TurtleRefueling")
  65. end
  66. turtle.select(u)
  67. end
  68.  
  69. --Item slot selection , for block selection (ignores first item slot which is usually reserved for fuel)
  70. function SlotSelection()
  71. itemdetail = turtle.getItemDetail()
  72. if turtle.getItemCount(u) == 0 or bb ~= itemdetail.name then
  73. for k=2,16 do
  74. if turtle.getItemCount(u) == 0 or bb ~= itemdetail.name then
  75. turtle.drop()
  76. if u < 16 then
  77. u=u+1
  78. turtle.select(u)
  79. else
  80. turtle.select(2)
  81. u=2
  82. end
  83. end
  84. end
  85. end
  86.  
  87. end
  88.  
  89. --Place underneath (down) block (even on water and lava)
  90. function BlockplaceDown()
  91. SlotSelection()
  92. if turtle.detectDown() then
  93. bool,data = turtle.inspectDown()
  94. if data.name == "minecraft:lava" and data.name == "minecraft:water" and data.name == "minecraft:flowing_water" and data.name == "minecraft:flowing_lava" then
  95. turtle.placeDown()
  96. end
  97. else
  98. turtle.placeDown()
  99. end
  100. end
  101.  
  102. --graveldigforward
  103. function graveldig() --Gravel Shield for digging and the digging
  104. os.sleep(9/20)
  105. if turtle.detect() then
  106. bool,data=turtle.inspect()
  107. while data.name ~= "minecraft:flowing_water" and data.name ~= "minecraft:flowing_lava" and turtle.inspect()~= false do
  108. turtle.dig()
  109. os.sleep(9/20)
  110. bool,data=turtle.inspect()
  111. end
  112. end
  113. end
  114.  
  115. --Dig N move
  116. function dignmove()
  117. Fdig()
  118. graveldig()
  119. turtle.forward()
  120. end
  121.  
  122.  
  123. function round(num)
  124. math.floor(num+0.5)
  125. end
  126.  
  127. --Max value in a table
  128. function maxtab(a)
  129. local values = {}
  130. for k,v in pairs(a) do
  131. values[#values+1] = v
  132. end
  133. table.sort(values)
  134. return values[#values]
  135. end
  136.  
  137.  
  138.  
  139.  
  140. --Code:
  141.  
  142. while X < Xmax do
  143. print("Table Filling")
  144. Eq()
  145. Zx[X] = EqZ --Filling in the locations of the blocks in the table
  146.  
  147. X = X + i --Upcounting of the increment
  148.  
  149. if dim == 3 then
  150. while Z < Zmax do
  151. Yz[Eqy] = Z --Filling in the locations of the blocks in the table
  152. Z = Z + i --Upcounting of the increment
  153. end
  154. end
  155. end
  156.  
  157. while locZ < tabZmax do
  158. tabZmax = maxtab(Zx)
  159. print("Strip building")
  160. while locX < Xmax do
  161.  
  162. if round(Zx[locX]) == locZ then
  163. BlockplaceDown() --Does NOT replace blocks (except water/lava)
  164. end
  165.  
  166. dignmove()
  167. locX = locX + 1 --Keeps track of the X coordinate
  168. TurtleRefuel()
  169. end
  170.  
  171. if math.mod(locX,2) == 0 and locZ < tabZmax then --Turn around at the end of a 'strip'
  172. turtle.turnLeft()
  173. dignmove()
  174. turtle.turnLeft()
  175. else
  176. turtle.turnRight()
  177. dignmove()
  178. turtle.turnRight()
  179. end
  180. locZ = locZ + 1 --Keeps track of the Z coordinate change in the math.mod block
  181. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement