Advertisement
Guest User

Untitled

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