Advertisement
artengineer08

Replicate

Jan 18th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.85 KB | None | 0 0
  1. --Replicate by Booyaah
  2.  
  3. --TO DO LIST:
  4. --fix veinmine
  5. --dont break saplings when looking for sugarcane
  6. --Stop looking for sugarcane once it's found
  7. --The last treefarm didn't make sure there was enough fuel
  8. --!make a rep.craft (common patterns + custom patterns option)
  9. --then make a more developed treefarm area (and a timer for how long they have been growing) and place a torch at 0,0,0 (crafting a torch could use a better crafting API)
  10. --fix the multiple turns during treeSearch (make pathing API?)
  11. --add: making decisions based on how many items we have (like the initial dirt gather and treeSearching)
  12.  
  13. --DEBUG CONTROLS:
  14. debugPause=false
  15. skiptreeSearch=false
  16.  
  17. --EMERGENCY WOOD HARVESTING
  18. --Because: Needs fuel badly
  19. rep.firstTree()
  20.  
  21. --SETTING A CHEST LOCATION
  22. --Because: doesn't have any storage locations
  23. t.goto(0,0,-1,0,"dig")
  24. rep.saveLocation("chest1","down")
  25.  
  26. --GATHERING COBBLE
  27. --Because: idk?
  28. rep.firstCobble()
  29. rep.gotoLocation("chest1")
  30.  
  31. --TREE SEARCHING
  32. --Because: still low on fuel
  33. t.goto(0,0,-4,0,"dig")
  34. rep.treeSearch()
  35. t.goto(0,0,0,0,"dig")
  36. rep.gotoLocation("chest1")
  37.  
  38. --CRAFTING CHEST (INCLUDES CRAFTING PLANKS AND PLACING CHEST)
  39. --Because: no chest exists in first chest position
  40. t.displayAction("Crafting")
  41. t.dropAllExcept("down","log")
  42. t.transferItem("log",_G.woodSlot)
  43. t.select(_G.woodSlot)
  44. craftQuantity=turtle.getItemCount()-1
  45. t.suck("down","all")
  46. craftResult=rep.craftItem("planks",craftQuantity)
  47. craftResult=rep.craftItem("chest", 1) --What if this fails?
  48. rep.gotoLocation("chest1")
  49. t.place("down","chest") --what if this fails?
  50.  
  51. --MAKING TREE FARM
  52. --Because: no tree farm is known
  53. t.displayAction("placing saplings")
  54. t.condenseInventory()
  55. t.select(1)
  56.  
  57. --could add a treeSearch here: to check over the minedown loacations but it takes too long and gets boring to watch.
  58. --t.goto(0,0,7,2,"dig") --don't forget to jump over the torch on the way
  59. --rep.treeSearch()
  60. local oakCount=0
  61. local nonoakCount=0
  62. for i=1,16 do   --figuring out which type of saplings to plant
  63.     if turtle.getItemCount(i)>0 then
  64.         local countDetails=t.getDetails(i)
  65.         if countDetails.name=="sapling" then
  66.             if countDetails.nickname=="oak_sapling" then
  67.                 oakCount=oakCount+turtle.getItemCount(i)
  68.             else
  69.                 nonoakCount=nonoakCount+turtle.getItemCount(i)
  70.             end
  71.         end
  72.     end
  73. end
  74. if oakCount>nonoakCount then
  75.     for i=1,16 do
  76.         local countDetails=t.getDetails(i)
  77.         if countDetails.name=="sapling" then
  78.             if countDetails.nickname=="oak_sapling" then
  79.             else
  80.                 t.select(i)
  81.                 turtle.refuel()
  82.             end
  83.         end
  84.     end
  85.     t.select(1)
  86.     rep.createTreeFarm(0,0,-1,0,"oak_sapling")
  87. else
  88.     for i=1,16 do
  89.         if t.getDetails(i).nickname=="oak_sapling" then
  90.             t.select(i)
  91.             turtle.refuel()
  92.         end
  93.     end
  94.     t.select(1)
  95.     rep.createTreeFarm(0,0,-1,0,"not_oak_sapling")
  96. end
  97.  
  98.  
  99. --if I treesearch above Minedown locations then I can createTreeFarm(0,0,11,2)
  100.  
  101. --INITIAL SHALLOW MINING
  102. --Because: a furnace is needed and no cobble is owned, also hoping to find coal
  103. rep.gotoLocation("chest1")
  104. t.condenseInventory()
  105. t.dropAllExcept("down","planks","log","coal")
  106.  
  107. t.displayAction("Mining Down")
  108. rep.mineDown(1,0,2,2,14,"sides")        --how far down do I need to go? Based on what I find? (coal/iron/cobble)
  109. rep.mineUp(2,_G["y"],4,2,14,"sides")
  110. t.f(1,"dig")
  111. while t.findItem("stone") do    --drop all andesite, diorite and granite
  112.     t.drop("down","stone")
  113. end
  114.  
  115. t.displayAction("Covering Hole")
  116. for i=1,4 do
  117.     t.place("front","cobblestone")
  118.     t.d(1)
  119. end
  120. t.r(1,"dig")
  121. t.place("down","cobblestone")
  122. t.goto(1,0,2,2,"dig")
  123. t.goto(1,-1,2,2,"dig")
  124. for i=1,4 do
  125.     t.place("front","cobblestone")
  126.     t.d(1)
  127. end
  128. t.r(1,"dig")
  129. t.place("down","cobblestone")
  130. t.a(2)
  131. t.w(2,"dig")
  132. t.dig("down")
  133. t.place("down","cobblestone")
  134. t.w(1,"dig")
  135. t.dig("down")
  136. t.place("down","cobblestone")
  137. --done filling in the mineDown hole
  138.  
  139. t.goto(0,0,0,1,"dig")   --placing dirt/cobble around the chests and signs
  140. t.w(1,"dig")
  141. t.place("down","dirt")
  142. t.place("down","cobblestone")
  143. t.dig("up")
  144. t.a(1)
  145. for i=1,5 do
  146.     t.w(1,"dig")
  147.     t.dig("up")
  148.     t.place("down","dirt")
  149.     t.place("down","cobblestone")
  150. end
  151. t.a(1)
  152. for i=1,2 do
  153.     t.w(1,"dig")
  154.     t.dig("up")
  155.     t.place("down","dirt")
  156.     t.place("down","cobblestone")
  157. end
  158. t.a(1)
  159. for i=1,5 do
  160.     t.w(1,"dig")
  161.     t.dig("up")
  162.     t.place("down","dirt")
  163.     t.place("down","cobblestone")
  164. end
  165. t.a(1)
  166. t.w(1,"dig")
  167. t.dig("up")
  168. t.place("down","dirt")
  169. t.place("down","cobblestone")
  170. t.a(1)
  171. t.w(1)
  172. for i=1,4 do
  173.     t.w(1,"dig")
  174.     t.dig("up")
  175.     t.dig("down")
  176. end
  177.  
  178. rep.gotoLocation("chest1")
  179. t.checkFuel(4)
  180. t.dropAllExcept("down","cobblestone")
  181.  
  182. --CRAFTING A FURNACE
  183. --Because: no furnace existing
  184. t.displayAction("crafting furnace")
  185. local _,cobbleCount=t.findItem("cobblestone") --should first check to make sure we have 8 cobble...
  186.  
  187.  
  188. if cobbleCount>=8 then  --should do something different if we don't have enough cobble
  189.     craftResult=rep.craftItem("furnace", 1) --should do something different if the crafting didn't work...
  190. end
  191. ---------------------------------------
  192. t.d(1)
  193. t.r(1)
  194.  
  195. t.place("up","furnace")
  196. t.a(1)
  197. t.select(1)
  198. t.f(1)
  199. t.suck("down","all")
  200.  
  201.  
  202. --MAKING CHARCOAL
  203. --Because: want to make a torch per competition requirements (no iron yet so we dont need it for smelting
  204. t.displayAction("Making Charcoal")
  205. t.checkFuel(12)
  206. t.condenseInventory()
  207. t.r(1)
  208. rep.smelt("log",1,"planks",1)
  209. t.displayAction("Waiting4Charcoal")
  210. for i=9,1,-1 do
  211.     term.setCursorPos(18,1)
  212.     term.write(i.." ")
  213.     sleep(1)
  214. end
  215. term.setCursorPos(17,1)
  216. term.write("   ")
  217. t.suck("up")
  218.  
  219.  
  220. --CRAFTING TORCH
  221. --competition requirement
  222. t.displayAction("Crafting Torch")
  223. t.checkFuel(20)
  224. t.f(1)
  225.  
  226. craftResult=rep.craftItem("stick",1)
  227.  
  228. craftResult=rep.craftItem("torch",1)
  229.  
  230. t.goto(0,0,1,2,"dig")
  231. t.place("down","dirt")
  232. t.s(1)
  233. t.place("front","torch")
  234.  
  235. --CRAFTING SIGN
  236. --for entertainment
  237. rep.gotoLocation("chest1")
  238. t.displayAction("Crafting Sign")    --Better check you have enough planks to do this
  239. t.checkFuel(20)
  240.  
  241. craftResult=rep.craftItem("sign",1)
  242.  
  243. t.goto(0,0,0,1,"dig")
  244. rep.saveLocation("sign1","front")
  245. rep.placeSign("front","Gone Mining.\nWill be back\nsoon.\n-Turtle ".._G.turtleNumber)
  246. t.goto(0,0,-2,1,"dig")
  247. rep.saveLocation("sign2","front")
  248. t.select(t.findItem("sign"))
  249. rep.placeSign("front","Careful:\nIt's a long\n way down.")
  250. rep.gotoLocation("chest1")
  251. --collect everything
  252. t.suck("down","all")
  253. t.condenseInventory()
  254. t.select(1)
  255.  
  256. --going Diamond Mining (INSTEAD SHOULD PROBABLY GATHER MORE WOOD if neeed AND LOOK FOR REEDS)
  257.  
  258. --drop the garbage
  259. theSlot,currentLogs=t.findItem("logs")
  260.  
  261. if currentLogs>1 then
  262.     craftResult=rep.craftItem("planks",currentLogs-1)
  263. end
  264.    
  265. t.suck("down","all")
  266. t.dropAllExcept("down","planks","coal") --if there are more than 64 planks or more than 1 type of plank then the turtle will probably not have enough planks to make it through mining
  267. t.condenseInventory()
  268.  
  269. t.displayAction("Diamond Mining!")
  270. t.displayAction("Bedrock Level")    --we should be mining veins during this time.
  271. rep.findBedrockLevel(0,0,-2,0)
  272. t.displayAction("Diamond Mining!")
  273.  
  274. t.condenseInventory()
  275.  
  276. rep.diamondMine(16,6,false) -- false means drop extra cobble and dirt, return to surface when required items are gathered. After a while, go harvest the trees that were planted earlier
  277.  
  278. --LOOK AT REFUEL FUNCTION: it needs to keep refueling until it has more than target, the function was only refueling one of each item and then saying it's out of fuel.
  279.  
  280. t.displayAction("storing items")
  281.  
  282. t.goto(0,_G.bedrockLevel,-2,1,"dig")
  283.  
  284. while _G["y"]<-1 do --veinmine on the way back up
  285.     possibleVein=t.getDetails("front").name
  286.     if possibleVein=="diamond_ore" or possibleVein=="coal_ore" or possibleVein=="iron_ore" or possibleVein=="gold_ore" or possibleVein=="redstone_ore" or possibleVein=="lapis_ore" then _G.veins[#_G.veins+1]={_G.x,_G.y,_G.z,_G.u,"front",possibleVein} end
  287.     if #_G.veins>0 then t.mineVein(_G["x"],_G["y"],_G["z"],_G["u"],"forward") end
  288.     t.r(1,"dig")
  289. end
  290.  
  291. t.goto(0,-1,-2,0,"dig")
  292. t.place("forward","cobblestone")
  293. t.place("down","cobblestone")
  294. t.r(1,"dig")
  295. t.a(1)
  296. t.dropAll("down","cobblestone") --START TIMER! if it reaches 4 minutes then we need to go back and suck/drop all the extra cobblestone that was dropped on the ground next to the storage chest.
  297. t.dropAll("down","dirt")
  298. t.goto(0,0,-1,2,"dig")
  299. t.dropAllExcept("down","coal","planks")
  300. t.suck("down","all")
  301. t.dropAllExcept("down","coal","planks","sapling","dirt","torch")    --what if there is a bunch of junk in the chest and torches don't fit in the inventory
  302. t.condenseInventory()
  303.  
  304. rep.treeFarm(6)
  305.  
  306. rep.gotoLocation("chest1")  --crafting the wood that was just collected so it can be used for crafting
  307. t.suck("down","all")
  308. craftResult=rep.craftItem("planks",64)
  309. t.drop("down","planks")
  310.  
  311. theSlot,currentLogs=t.findItem("logs")
  312. if currentLogs>1 then
  313.     craftResult=rep.craftItem("planks",currentLogs-1)
  314. end
  315. t.suck("down","all")
  316.  
  317. t.checkFuel(20)
  318. t.displayAction("crafting chest")
  319.  
  320. --UH, what if none of the saplings grew and I have no wood? (logCount<2)
  321. craftResult=rep.craftItem("chest",2)
  322.  
  323. t.displayAction("storing cobble")
  324. t.goto(0,0,-3,0,"dig") --UH, what if I was out of fuel and now I just consumed my chest to refuel?? WHat now??
  325. t.dig("down")
  326. t.place("down","chest")
  327. rep.saveLocation("chest2","down")
  328.  
  329. t.s(1)
  330. t.suck("down","all")
  331. t.s(1)
  332. t.suck("down","all")
  333. t.condenseInventory()
  334. t.w(2,"dig")
  335.  
  336. t.place("down","chest")
  337. t.dropAll("down","cobblestone")
  338. t.dropAll("down","dirt")
  339. t.s(2)
  340. t.suck("down","all")
  341. t.w(2,"dig")
  342. t.d(1)
  343. rep.placeSign("front","Cobblestone\nand\nDirt")
  344. rep.saveLocation("sign3","front")
  345.  
  346. t.goto(0,0,-1,2,"dig")
  347. t.dropAllExcept("down","planks","log","coal")
  348. t.condenseInventory()
  349.  
  350. t.displayAction("Making Charcoal")  --on a testrun: didnt have enough planks to cook all the wood, so time was wasted sitting there while no charcoal was cooking
  351. rep.gotoLocation("sign1")               --on this testrun: ran out of logs so I have 27 planks in there with nothing to cook
  352. rep.placeSign("front","Producing\nCharcoal")
  353. t.goto(0,3,-1,0,"dig")
  354.  
  355. --===============================
  356. --MOVE TO THE rep function
  357. logCount=turtle.getItemCount(t.findItem("log"))
  358. t.drop("down","log",logCount-4) --UH, what if there aren't enough logs?
  359. t.s(1)
  360. t.goto(0,2,0,0,"dig")
  361. plankCount=turtle.getItemCount(t.findItem("planks"))
  362. t.drop("front","planks",plankCount-4)   --UH, what if there aren't enough planks?
  363. t.f(1)
  364. t.w(1)
  365.  
  366. t.displayAction("Waiting4Charcoal") --WHILE WAITING FOR COOKING CHARCOAL, WE COULD JUST GRAB THE FIRST 2 CHARCOAL AND GO MAKE SURE THE SAPLINGS HAVE ROOM TO GROW.
  367. waitTime=10*(logCount-4) --seconds (should be 10 seconds * #of logs)
  368. if waitTime<2 then waitTime=2 end
  369. for i=waitTime,1,-1 do
  370.     term.setCursorPos(16,1)
  371.     term.write(i.." ")
  372.     sleep(1)
  373. end
  374. term.setCursorPos(15,1)
  375. term.write("     ")
  376. t.suck("up")   
  377. t.s(1)
  378. t.r(1,"dig")
  379. t.suck("forward")
  380. t.r(1,"dig")
  381. t.w(1,"dig")
  382. t.suck("down")
  383. t.s(1)
  384. t.f(1)
  385. t.condenseInventory()
  386.  
  387. t.displayAction("crafting torches")
  388. rep.gotoLocation("origin")
  389. rep.gotoLocation("chest1")
  390. t.checkFuel(20)
  391.  
  392. craftResult=rep.craftItem("stick",1)    --UH, what if we have more than 16 types of items in the chest and sticks/charcoal are not amng the items sucked up?
  393. craftResult=rep.craftItem("torch",1)    --should probably flow the items instead of this... (see above)
  394.  
  395. if turtle.getFuelLevel()<750 then
  396.     while t.findItem("charcoal") and turtle.getFuelLevel()<5000 do
  397.         turtle.select(t.findItem("charcoal"))
  398.         turtle.refuel(1)
  399.     end
  400.     t.select(_G.selectedSlot)
  401. end
  402.  
  403. t.w(1,"dig")
  404. for i=1,16 do   --dropping all the junk down the hole
  405.     if turtle.getItemCount(i)>0 then
  406.         if t.getDetails(i).name=="stone" or t.getDetails(i).name=="red_flower" or t.getDetails(i).name=="yellow_flower" or t.getDetails(i).name=="brown_mushroom" or t.getDetails(i).name=="red_mushroom" or t.getDetails(i).name=="wheat_seeds" then
  407.             t.select(i)
  408.             turtle.dropDown(64)
  409.         end
  410.     end
  411.     t.dropExtra("down","cobblestone")   --drop the extra resources so they don't fill up the chest
  412.     t.dropExtra("down","dirt")
  413. end
  414. t.w(1,"dig")
  415. for i=1,16 do   --dropping all the dirt/cobble in the chest
  416.     if turtle.getItemCount(i)>0 then
  417.         if t.getDetails(i).name=="dirt" or t.getDetails(i).name=="cobblestone" then
  418.             t.select(i)
  419.             turtle.dropDown(64)
  420.         end
  421.     end
  422. end
  423. t.select(1)
  424. t.s(2)
  425. rep.treeFarm(6)
  426.  
  427. ---------------------------------------------- DOUBLE CHECK that chest1 doesn't have junk in it like cobble/andesite/flowers
  428. t.displayAction("Diamond Mining!")
  429. rep.gotoLocation("sign1")
  430. rep.placeSign("front","Diamond\nmining.\n2nd trip\n-Turtle "..turtleNumber)
  431. t.a(1)
  432. t.w(1,"dig")
  433. theSlot,currentPlanks=t.findItem("planks")  --this can get broken if you have 1 birchwood and 30 oak wood in inventory
  434. if turtle.getFuelLevel()<350 and currentPlanks<25 then  --if you might run out of fuel then craft some wood into planks
  435.     planksNeeded=math.ceil((25-currentPlanks)/4)
  436.     print(planksNeeded)
  437.     t.dropAllExcept("down","log")
  438.     t.dropExtra("down","log")
  439.     turtle.craft(planksNeeded)
  440. end
  441. t.suck("down","all")
  442. t.dropAllExcept("down","planks","coal")
  443. t.condenseInventory()
  444. t.goto(0,0,-2,2,"dig")
  445. while _G["y"]>_G.bedrockLevel do
  446.     possibleVein=t.getDetails("front").name
  447.     if possibleVein=="diamond_ore" or possibleVein=="coal_ore" or possibleVein=="iron_ore" or possibleVein=="gold_ore" or possibleVein=="redstone_ore" or possibleVein=="lapis_ore" then _G.veins[#_G.veins+1]={_G.x,_G.y,_G.z,_G.u,"front",possibleVein} end
  448.     if #_G.veins>0 then t.mineVein(_G["x"],_G["y"],_G["z"],_G["u"],"forward") end
  449.     t.f(1,"dig")
  450. end
  451.  
  452. rep.diamondMine(16,6,false)
  453.  
  454. t.displayAction("storing items")
  455. t.goto(0,_G.bedrockLevel,-2,3,"dig")
  456.  
  457. while _G["y"]<-1 do
  458.     possibleVein=t.getDetails("front").name
  459.     if possibleVein=="diamond_ore" or possibleVein=="coal_ore" or possibleVein=="iron_ore" or possibleVein=="gold_ore" or possibleVein=="redstone_ore" or possibleVein=="lapis_ore" then _G.veins[#_G.veins+1]={_G.x,_G.y,_G.z,_G.u,"front",possibleVein} end
  460.     if #_G.veins>0 then t.mineVein(_G["x"],_G["y"],_G["z"],_G["u"],"forward") end
  461.     t.r(1,"dig")
  462. end
  463.  
  464. t.goto(0,-1,-2,0,"dig")
  465.  
  466. --dropping off extra cobble
  467. t.dropExtra("front","cobblestone")
  468. t.goto(0,0,-1,2,"dig")
  469.  
  470. t.display("pause 13",32,13,8)
  471. if debugPause==true then read() end
  472.  
  473. t.checkFuel(20)
  474. --craft 2 chests
  475.  
  476. --if there aren't enough planks, then craft them out of wood (logs)
  477. --SHOULD ADD: IF THERE ARE NO LOGS, GO FARM THEM OR TREESEARCH THEM
  478.  
  479. t.suck("down","all")
  480.  
  481.  
  482. theSlot,currentPlanks=t.findItem("planks")
  483. if currentPlanks<22 then    --if you might run out of fuel then craft some wood into planks
  484.     planksNeeded=math.ceil((24-currentPlanks)/4)
  485.     t.suck("down","all")    --what if we have >16 stacks of stuff in the chest (should flow items)
  486.     t.dropAllExcept("down","log")
  487.     t.dropExtra("down","log")
  488.     turtle.craft(planksNeeded)
  489.     t.drop("down","log")
  490.     t.suck("down","all")
  491. end
  492. t.condenseInventory()
  493. t.dropAllExcept("down","planks")
  494. t.dropExtra("down","planks")
  495.  
  496. --=============================
  497. --SWITCH THIS TO rep FUNCTION
  498. craftResult=rep.craftItem("chest",2)    --UH, what if we don't have 16 planks?
  499. --[[   
  500. t.transferItem("planks",_G.plankSlot)
  501. t.select(_G.plankSlot)
  502.             --Double-check this is fixed:
  503. for k=1,11 do
  504.     if k~=4 and k~=6 and k~=8 then turtle.transferTo(k,2) end
  505. end
  506. turtle.dropDown()
  507. turtle.craft(2)
  508. doubleCheck=t.findItem("chest")
  509. if doubleCheck==nil then t.display("error crafting 2 chests",15,12,25) end
  510. --use the extra chest to sort out inventory============= "flow inventory"
  511. t.goto(0,0,-1,1)
  512. t.place("forward","chest")
  513. t.suck("down","all")
  514. t.dropAllExcept("front","planks","stick")
  515. t.suck("down","all")
  516. t.dropAllExcept("front","planks","stick")   --UH, what if we magically don't have any sticks? (there should still be 2 sticks in there... but they could disappear...)
  517.  
  518. --crafting sign
  519. t.transferItem("stick",10)
  520. t.transferItem("planks",_G.plankSlot)
  521. t.select(_G.plankSlot)
  522.  
  523. for i=1,7 do
  524.     if i~=4 then turtle.transferTo(i,1) end
  525. end
  526. for i=1,16 do
  527.     if i~=1 and i~=2 and i~=3 and i~=5 and i~=6 and i~=7 and i~=10 then
  528.         t.select(i)
  529.         turtle.dropDown()
  530.     end
  531. end
  532. t.select(4)
  533. turtle.craft(1) --sign crafted*********
  534. doubleCheck=t.findItem("sign")
  535. if doubleCheck==nil then t.display("error crafting signs",15,12,25) end
  536. --]]
  537.  
  538. --Make a list of which items go in which chest
  539. --====================================================================================================================
  540.  
  541. t.drop("down","stick")  --CAN WE JUST USE dropAllExcept here instead? not needed?
  542. t.suck("front","all")
  543. t.dropAll("down","sapling")
  544. t.dropAll("down","torch")
  545. t.dropAll("down","apple")
  546. t.dropAll("down","log")
  547. t.dropAll("down","wheat_seeds")
  548.  
  549. t.suck("front","all")
  550. t.dropAll("down","sapling")
  551. t.dropAll("down","torch")
  552. t.dropAll("down","apple")
  553. t.dropAll("down","log")
  554. t.dropAll("down","wheat_seeds")
  555.  
  556. t.dig("front")
  557. rep.gotoLocation("chest2")
  558. t.dropAll("down","cobblestone")
  559. t.dropAll("down","dirt")
  560. t.dropAll("down","gravel")
  561. t.w(2,"dig")
  562. t.dig("down")
  563. t.place("down","chest")
  564. rep.saveLocation("chest3","down")
  565. t.dropAll("down","iron_ore")
  566. t.dropAll("down","dye") --lapis
  567. t.dropAll("down","redstone")
  568. t.dropAll("down","gold_ore")
  569. t.dropAll("down","diamond")
  570. t.dropAll("down","emerald")
  571. t.dropAll("down","obsidian")
  572. t.dropAll("down","flint")
  573.  
  574. t.d(1)
  575. rep.placeSign("front","Mined\nMaterials")
  576. rep.saveLocation("sign4","front")
  577.  
  578. t.d(1)
  579. t.w(2,"dig")
  580. t.a(1)
  581.  
  582. t.display("pause 14",32,13,8)
  583. if debugPause==true then read() end
  584.  
  585. --updating sign to show that gravel is stored here too.
  586. rep.placeSign("front","Cobblestone,\nDirt and Gravel")
  587.  
  588. t.goto(0,0,-1,2,"dig")
  589. t.condenseInventory()
  590. --if we don't have 200 fuel we need to make sure we have planks to get us around
  591. if turtle.getFuelLevel()<200 and t.getDetails(t.findItem("planks")).count<14 then
  592.     t.suck("down","all")
  593.     local logCount=t.getDetails("log").count
  594.     if logCount>1 then craftResult=rep.craftItem("planks",logCount-1) end
  595. end
  596.  
  597. rep.treeFarm(6)
  598.  
  599. rep.gotoLocation("chest1")
  600. --t.goto(0,0,-1,0,"dig")
  601. t.dropAll("down","sapling")
  602. t.dropAll("down","torch")
  603. t.dropAll("down","dirt")
  604. t.dropAll("down","log")
  605. t.dropAll("down","apple")
  606.  
  607. --time to go look for sand and reeds?
  608.  
  609. t.display("pause 15",32,13,8)
  610. if debugPause==true then read() end
  611.  
  612. t.select(1)
  613.  
  614. --KEEPS RUNNING OUT OF PLANKS BUT THERE ARE PLENTY OF LOGS: need to craft planks and refuel
  615.  
  616. --clears out all the blocks around the treefarm (needed for large initial trees and hills)
  617.  
  618. --if it doesnt have fuel then it should keep treefarming
  619. t.checkFuel(750)
  620.  
  621. t.displayAction("Landscaping")
  622. rep.gotoLocation("sign1")
  623. rep.placeSign("front","Landscaping")
  624. t.select(1)
  625.  
  626. t.goto(1,1,2,3,"dig")
  627.  
  628. function clearArea(length)
  629.     for i=1,length do
  630.         if t.getDetails("up").name=="furnace" then  else t.dig("up") end
  631.         if turtle.detectDown() then
  632.             local checkName=t.getDetails("down").name
  633.             if checkName=="torch" or checkName=="standing_sign" or checkName=="wall_sign" then else t.dig("down") end
  634.         end
  635.         t.w(1,"dig")
  636.     end
  637.     if t.getDetails("up").name=="furnace" then  else t.dig("up") end
  638.     if turtle.detectDown() then
  639.         local checkName=t.getDetails("down").name
  640.         if checkName=="torch" or checkName=="standing_sign" or checkName=="wall_sign" then else t.dig("down") end
  641.     end
  642. end
  643.  
  644. t.goto(7,2,2,0,"dig")
  645.  
  646. for i=1,3 do
  647.     clearArea(14)
  648.     t.d(1)
  649.     t.w(1,"dig")
  650.     t.d(1)
  651.    
  652.     clearArea(14)
  653.     t.a(1)
  654.     t.w(1,"dig")
  655.     t.a(1)
  656.    
  657. end
  658.  
  659. clearArea(14)
  660.  
  661. t.d(1)
  662. t.w(1,"dig")
  663. t.d(1)
  664. clearArea(10)
  665. t.r(1,"dig")
  666. t.w(2,"dig")
  667. t.f(1,"dig")
  668. clearArea(2)
  669.  
  670. t.a(1)
  671. t.w(1,"dig")
  672. t.a(1)
  673.  
  674. for i=1,3 do
  675.     clearArea(14)
  676.     t.d(1)
  677.     t.w(1,"dig")
  678.     t.d(1)
  679.    
  680.     clearArea(14)
  681.     t.a(1)
  682.     t.w(1,"dig")
  683.     t.a(1)
  684.    
  685. end
  686.  
  687. t.goto(7,4,2,0,"dig")
  688.  
  689. for i=1,7 do
  690.     clearArea(14)
  691.     t.d(1)
  692.     t.w(1,"dig")
  693.     t.d(1)
  694.    
  695.     clearArea(14)
  696.     t.a(1)
  697.     t.w(1,"dig")
  698.     t.a(1)
  699.    
  700. end
  701.  
  702. t.goto(7,7,2,0,"dig")
  703.  
  704. for i=1,7 do
  705.     clearArea(14)
  706.     t.d(1)
  707.     t.w(1,"dig")
  708.     t.d(1)
  709.    
  710.     clearArea(14)
  711.     t.a(1)
  712.     t.w(1,"dig")
  713.     t.a(1)
  714.    
  715. end
  716.  
  717. t.goto(0,1,0,0,"dig")
  718. t.goto(0,0,-1,0,"dig")
  719.  
  720. rep.treeFarm(10)
  721. t.goto(0,0,-1,0,"dig")
  722.  
  723. --add one last check to make sure no dirt/junk in the chest1
  724. t.checkFuel(150)
  725. t.goto(0,1,0,0,"dig")
  726. -- t.goto(0,1,7,2,"dig")    --don't forget to jump over the torch on the way
  727. -- rep.treeSearch()
  728. -- t.goto(0,1,0,0,"dig")
  729. rep.gotoLocation("chest1")
  730. t.suck("down","all")
  731. t.dropAllExcept("down","planks","dirt","sapling","torch")
  732. t.w(2)
  733. t.suck("down","all")
  734. t.dropAll("down","cobblestone")
  735. t.dropAll("down","gravel")
  736. t.condenseInventory()
  737. t.goto(0,1,0,0,"dig")
  738. t.checkFuel(150)
  739.  
  740. --[[
  741. local oakCount=0
  742. local nonoakCount=0
  743. for i=1,16 do   --figuring out which type of saplings to plant
  744.     if turtle.getItemCount(i)>0 then
  745.         local countDetails=t.getDetails(i)
  746.         if countDetails.name=="sapling" then
  747.             if countDetails.nickname=="oak_sapling" then
  748.                 oakCount=oakCount+turtle.getItemCount(i)
  749.             else
  750.                 nonoakCount=nonoakCount+turtle.getItemCount(i)
  751.             end
  752.         end
  753.     end
  754. end
  755. if oakCount>nonoakCount then
  756.     for i=1,16 do
  757.         local countDetails=t.getDetails(i)
  758.         if countDetails.name=="sapling" then
  759.             if countDetails.nickname=="oak_sapling" then
  760.             else
  761.                 t.select(i)
  762.                 turtle.refuel()
  763.             end
  764.         end
  765.     end
  766.     t.select(1)
  767.     rep.createTreeFarm(0,0,11,2,"oak_sapling")
  768. else
  769.     for i=1,16 do
  770.         if t.getDetails(i).nickname=="oak_sapling" then
  771.             t.select(i)
  772.             turtle.refuel()
  773.         end
  774.     end
  775.     t.select(1)
  776.     rep.createTreeFarm(0,0,11,2,"not_oak_sapling")
  777. end
  778. --]]
  779. t.goto(0,2,0,0,"dig")
  780. t.goto(0,0,0,0,"dig")   --to avoid breaking furnace
  781. t.goto(0,0,-3,0,"dig")
  782. t.dropAll("down","dirt")
  783. rep.gotoLocation("chest1")
  784. t.suck("down","all")
  785. t.dropAllExcept("down","log")
  786. if t.findItem("log") then craftResult=rep.craftItem("planks",64) end
  787. t.suck("down","all")
  788. t.dropAllExcept("down","planks")
  789. t.goto(0,0,-5,0,"dig")
  790. t.suck("down","all")
  791. t.dropAllExcept("down","iron_ore","gold_ore","planks")
  792.  
  793. rep.gotoLocation("chest1")
  794. t.checkFuel(16)
  795. t.r(1,"dig")
  796.  
  797. theSlot,ironCount=t.findItem("iron_ore")
  798. if theSlot then
  799.     rep.smelt("iron_ore",ironCount,"planks", 64)
  800. end
  801. t.displayAction("Waiting4Iron")
  802. waitTime=10*(ironCount) --seconds (should be 10 seconds * #of smelting items)
  803. if waitTime<2 then waitTime=2 end
  804.  
  805. --Wait for smelt
  806. for i=waitTime,1,-1 do
  807.     term.setCursorPos(16,1)
  808.     term.write(i.." ")
  809.     sleep(1)
  810. end
  811. term.setCursorPos(15,1)
  812. term.write("     ")
  813. t.suck("up")   
  814. t.s(1)
  815. t.r(1,"dig")
  816. t.suck("forward")
  817. t.r(1,"dig")
  818. t.w(1,"dig")
  819. t.suck("down")
  820. t.s(1)
  821. t.f(2,"dig")
  822. t.w(1,"dig")
  823. t.condenseInventory()
  824.  
  825.  
  826.  
  827. theSlot,goldCount=t.findItem("gold_ore")
  828. if theSlot then
  829.     rep.smelt("gold_ore",goldCount,"planks", 64)
  830. end
  831. t.displayAction("Waiting4Gold")
  832. waitTime=10*(goldCount) --seconds (should be 10 seconds * #of smelting items)
  833. if waitTime<2 then waitTime=2 end
  834.  
  835. --Wait for smelt
  836. for i=waitTime,1,-1 do
  837.     term.setCursorPos(16,1)
  838.     term.write(i.." ")
  839.     sleep(1)
  840. end
  841. term.setCursorPos(15,1)
  842. term.write("     ")
  843. t.suck("up")   
  844. t.s(1)
  845. t.r(1,"dig")
  846. t.suck("forward")
  847. t.r(1,"dig")
  848. t.w(1,"dig")
  849. t.suck("down")
  850. t.s(1)
  851. t.f(2,"dig")
  852. t.w(1,"dig")
  853. t.condenseInventory()
  854.  
  855. t.goto(0,0,-5,0,"dig")
  856. t.drop("down","gold_ingot")
  857. rep.gotoLocation("chest1")
  858. theSlot,ironCount=t.findItem("iron_ingot")
  859. if ironCount>=3 then craftResult=rep.craftItem("bucket",1) end
  860. t.goto(0,0,-5,0,"dig")
  861. t.drop("down","iron_ingot")
  862. rep.gotoLocation("chest1")
  863.  
  864. rep.treeFarm(10)
  865. t.goto(0,0,-1,0,"dig")
  866.  
  867. t.suck("down","all")
  868. t.goto(0,0,-3,0,"dig")
  869. t.dropAll("down","dirt")
  870. t.dropAll("down","stone")
  871. t.dropAll("down","gravel")
  872. t.dropAll("down","cobblestone")
  873. t.goto(0,0,-1,0,"dig")
  874. t.dropAllExcept("down","coal","planks","log","bucket")
  875. t.condenseInventory()
  876.  
  877. t.goto(0,1,10,3,"dig")
  878. rep.sugarCaneSearch(20,25,15)
  879. t.goto(0,1,-15,1,"dig")
  880. rep.sugarCaneSearch(20,25,15)
  881. t.goto(0,1,-1,0,"dig")
  882. t.goto(0,0,-1,0,"dig")
  883. rep.treeFarm(10)
  884. t.goto(0,0,-1,0,"dig")
  885.  
  886. --[[
  887. --=================================
  888. --DEVELOPMENT
  889.  
  890. t.checkFuel(200)
  891. t.displayAction("sugarcane search")
  892. while t.getDetails("down").name=="none" do
  893.     if t.getDetails("front").name=="reeds" then harvestReedStalk() end
  894.     t.f(1,"nodig")
  895. end
  896. if t.getDetails("down").name=="water" then
  897.     --search around for sugarcane
  898. end
  899. --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement