Advertisement
fadfcax

Untitled

Jun 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.29 KB | None | 0 0
  1. local basex = 0
  2. local basey = 0
  3. local odwiertx = 0;
  4. local odwierty = 0;
  5. local limitx = 5;
  6. local limity = 5;
  7. local dol =0
  8. local obrot = 0
  9. local isworking = 0;
  10. local nazwa = "zolw"
  11. local aup = 0;
  12. local tue = 0;
  13. local ue = 0
  14. local rotated = 0
  15. local up = 0
  16. modem = peripheral.wrap("right")
  17. function dig()
  18. local p = 0
  19.  
  20. while true do
  21. local k5,urep = turtle.inspectDown()
  22. if urep.name == "minecraft:bedrock" then
  23. print("Koniec kopania")
  24. break
  25. end
  26.  
  27.  
  28.  
  29. turtle.digDown()
  30.  
  31. while turtle.down() == false do
  32. end
  33. dol = dol +1
  34. save()
  35. check()
  36.  
  37. p = p + 1;
  38. save()
  39.  
  40. end
  41.  
  42. local ukeh = obrot % 4
  43. while ukeh > 0 do
  44. turtle.turnRight()
  45. ukeh = ukeh - 1
  46. end
  47. end
  48. function update(p)
  49. local StudentNames ={nazwa,p}
  50. end
  51. function check()
  52.  
  53. local k3,pu = turtle.inspect();
  54. analyse(pu.name)
  55. turtle.turnLeft()
  56. obrot = obrot +1
  57. local k2, pup = turtle.inspect();
  58. analyse(pup.name)
  59. turtle.turnLeft()
  60. obrot = obrot +1
  61. local k1 ,pupp = turtle.inspect();
  62. analyse(pupp.name)
  63. turtle.turnLeft()
  64. obrot = obrot +1
  65. local k ,puppp = turtle.inspect();
  66. analyse(puppp.name)
  67.  
  68. end
  69. function wynurz()
  70. local pp = 0
  71. print(tostring(dol) )
  72. while dol > 0 do
  73.  
  74. while turtle.up() == false do
  75. turtle.digUp()
  76. end
  77. dol = dol - 1;
  78. save()
  79. end
  80. end
  81. function analyse(px)
  82.  
  83. if px == "minecraft:gold_ore" or px == "minecraft:iron_ore" or px == "minecraft:coal_ore" or px == "minecraft:lapis_ore" or px == "minecraft:diamond_ore" or px == "minecraft:redstone_ore" or px == "minecraft:emerald_ore" or px == "ProjRed:Exploration:projectred.exploration.ore" or px == "ThermalFoundation:Ore"or px == "denseores:block0"
  84. or px == "IC2:blockOreCopper" or px == "IC2:blockOreTin"or px == "IC2:blockOreUran"or px == "IC2:blockOreLead"or px == "TConstruct:SearedBrick" then
  85. turtle.dig()
  86.  
  87. end
  88. end
  89. function save()
  90. local h = fs.open("settings", "w")
  91. h.writeLine(tostring(limitx))
  92. h.writeLine(tostring(limity))
  93. h.writeLine(tostring(basex))
  94. h.writeLine(tostring(basey))
  95. h.writeLine(tostring(nazwa))
  96. h.writeLine(tostring(isworking))
  97. h.writeLine(tostring(dol))
  98. h.writeLine(tostring(up))
  99. h.writeLine(tostring(ue))
  100. h.writeLine(tostring(aup))
  101. h.writeLine(tostring(tue))
  102. h.writeLine(tostring(obrot))
  103. h.writeLine(tostring(rotated))
  104. h.close()
  105. end
  106. function looaddata()
  107. local ha = fs.open("settings", "r")
  108. limitx = tonumber(ha.readLine())
  109. limity = tonumber(ha.readLine())
  110. basex = tonumber(ha.readLine())
  111. basey = tonumber(ha.readLine())
  112. nazwa = ha.readLine()
  113. isworking = tonumber(ha.readLine())
  114. dol = tonumber(ha.readLine())
  115. up = tonumber(ha.readLine())
  116. ue = tonumber(ha.readLine())
  117. aup = tonumber(ha.readLine())
  118. tue = tonumber(ha.readLine())
  119. obrot = tonumber(ha.readLine())
  120. rotated = tonumber(ha.readLine())
  121. ha.close()
  122.  
  123. end
  124. function ref()
  125. local jur =0;
  126. while jur < 25 do
  127. jur=jur + 1
  128. turtle.refuel()
  129. end
  130. end
  131. ref()
  132.  
  133. if fs.exists("settings") then
  134.  
  135. looaddata()
  136. else
  137.  
  138.  
  139. print("Podaj rozmiar x ")
  140. limitx = tonumber(read())
  141. print("Podaj rozmiar y ")
  142. limity = tonumber(read())
  143. print("Podaj nazwe zolwia ")
  144. nazwa = read()
  145. print("Pomin x ")
  146. basex = tonumber(read())
  147. print("Pomin y ")
  148. basey = tonumber(read())
  149.  
  150.  
  151. end
  152.  
  153. function wroc()
  154.  
  155. turtle.turnLeft()
  156. turtle.turnLeft()
  157. while up > 0 do
  158. while turtle.forward() == false do
  159. local poriu = turtle.inspect();
  160. if poriu then
  161. turtle.dig()
  162. end
  163. end
  164. up = up -1
  165. save()
  166. end
  167.  
  168.  
  169. if ue > 0 then
  170. if rotated == 0 then
  171. turtle.turnRight()
  172. rotated = 1
  173. save()
  174. end
  175.  
  176.  
  177. while ue > 0 do
  178.  
  179. while turtle.forward() == false do
  180. local pori = turtle.inspect();
  181. if pori then
  182. turtle.dig()
  183. end
  184. end
  185. ue = ue -1
  186. save()
  187. end
  188. turtle.turnLeft()
  189. end
  190.  
  191. local kp = 1
  192.  
  193.  
  194. while kp < 17 do
  195. turtle.select(kp)
  196. turtle.drop(64)
  197. kp = kp +1
  198. end
  199.  
  200. while turtle.up() == false do end
  201. turtle.select(1)
  202. turtle.suck(8)
  203. ref()
  204. local sum = 200;
  205. sum = sum + basey * 3 + basex + 1;
  206. sum = sum + basex * 2 + basey;
  207. print("Problemy z paliwem !!")
  208. print("Potrzeba")
  209. print(tostring(sum))
  210. print("Paliwa")
  211. while turtle.getFuelLevel() < sum do
  212. turtle.select(1)
  213. turtle.suck(8)
  214. ref()
  215. end
  216. while turtle.down() == false do end
  217. turtle.turnRight()
  218. turtle.turnRight()
  219. if basex ~= limitx then
  220. basex = basex + 1
  221.  
  222. else
  223. basey = basey + 1
  224. basex = 0
  225. end
  226. end
  227. function idz()
  228.  
  229.  
  230. while aup > 0 do
  231.  
  232. while turtle.forward() == false do
  233. local pory = turtle.inspect();
  234. if pory then
  235. turtle.dig()
  236. end
  237. end
  238. aup = aup -1
  239. save()
  240. end
  241.  
  242.  
  243. if rotated == 0 then
  244. turtle.turnRight()
  245. rotated = 1
  246. save()
  247. end
  248.  
  249. while tue > 0 do
  250. while turtle.forward() == false do
  251. local por = turtle.inspect();
  252. if por then
  253. turtle.dig()
  254. end
  255. end
  256. tue = tue -1
  257. save()
  258. end
  259.  
  260. turtle.turnLeft()
  261. end
  262. while true do
  263.  
  264. save()
  265. if basex == limitx and basey == limity then
  266. print("Robota skonczona")
  267. error("koniec")
  268. end
  269.  
  270.  
  271. if isworking == 0 then
  272. isworking = 5
  273. aup = basex * 2 + basey
  274. tue = basey * 3 + basex +1
  275.  
  276. rotated = 0
  277. save()
  278. idz()
  279.  
  280. dol = 0
  281. obrot = 0
  282. isworking = 1
  283. save()
  284. dig()
  285. isworking = 2
  286. save()
  287. wynurz()
  288. up = basex * 2 + basey
  289. ue = basey * 3 + basex + 1
  290. isworking = 4;
  291. rotated = 0
  292. save()
  293. wroc()
  294. isworking = 0;
  295.  
  296.  
  297.  
  298. elseif isworking == 1 then
  299. dig()
  300. isworking = 2
  301. wynurz()
  302. up = basex * 2 + basey
  303. ue = basey * 3 + basex + 1
  304. isworking = 4;
  305.  
  306. rotated = 0
  307. save()
  308. wroc()
  309. isworking = 0;
  310. elseif isworking == 2 then
  311. wynurz()
  312. up = basex * 2 + basey
  313. ue = basey * 3 + basex + 1
  314. isworking = 4;
  315.  
  316. rotated = 0
  317. save()
  318. wroc()
  319. isworking = 0;
  320. elseif isworking == 4 then
  321. wroc()
  322.  
  323. elseif isworking == 5 then
  324. isworking = 5
  325.  
  326. save()
  327. idz()
  328.  
  329. dol = 0
  330. obrot = 0
  331. isworking = 1
  332. save()
  333. dig()
  334. isworking = 2
  335. save()
  336. wynurz()
  337. up = basex * 2 + basey
  338. ue = basey * 3 + basex + 1
  339. isworking = 4;
  340. rotated = 0
  341. save()
  342. wroc()
  343. isworking = 0;
  344. end
  345.  
  346.  
  347.  
  348. isworking = 0;
  349.  
  350.  
  351.  
  352.  
  353. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement