MarcosKoco

selfrep

Dec 17th, 2021 (edited)
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 157.32 KB | None | 0 0
  1. -- Minecraft 1.16.5
  2. -- Forge 36.1.66
  3. -- Mod: cc-tweaked-1.16.4-1.96.0.jar
  4.  
  5. local file = fs.exists("/Log.txt")
  6.  
  7. if file then
  8.     fs.delete("/Log.txt")
  9. end
  10.  
  11. local System = os -- Used for System things like os.time() to System.time()
  12. local Screen = term -- Used for Screen thing on the turtle or computer like term.clear() to Screen.clear()
  13. local Per = peripheral -- Used shortcut for peripheral
  14. local Text = textutils -- Used shortcut for textilils
  15. local Pack = Text.serialize -- Makes a new command for packing ( shortcut used from local Text)
  16. local UnPack = Text.unserialize -- Makes a new command for unpacking ( shortcut used from local Text)
  17.  
  18. local oldTurtle = turtle
  19.  
  20.  
  21. local Monitor = {}
  22.  
  23. Monitor[0] = Screen -- sets Monitor[0] to term
  24.  
  25. local Status = 1
  26.  
  27. local Sand = {}
  28. Sand.found = false
  29. local Water = {}
  30. Water.found = false
  31. local Mine = {}
  32. Mine.found = false
  33.  
  34. local chestSlot, bucketSlot, modemSlot = 16, 14, 15
  35.  
  36. local w, h = Monitor[0].getSize()
  37.  
  38. local Tools = {"computercraft:wireless_modem", "minecraft:diamond_pickaxe", "minecraft:crafting_table"}
  39. local Toolequip = turtle.equipRight
  40. local EquipLeft = false
  41. local EquipRight = false
  42.  
  43. local Chests = {[1] = {name = "rest"}, [2] = {name = "wood"}, [3] = {name = "stone"}, [4] = {name = "sand"}, [5] = {name = "redstone"}, [6] = {name = "iron"}, [7] = {name = "coal"}, [8] = {name = "diamond"}, [9] = {name = "sapling"}}
  44.  
  45. function SaveFile(File, Data, Do30)
  46.    
  47.     if File == "log" then
  48.        
  49.         local file = fs.exists("/Log.txt")
  50.        
  51.         if file then
  52.            
  53.             file = fs.open("/Log.txt", "a")
  54.            
  55.         else
  56.            
  57.             file = fs.open("/Log.txt", "w")
  58.            
  59.         end
  60.        
  61.         file.writeLine(Data)
  62.         file.close()
  63.        
  64.         if Do30 == true then
  65.            
  66.             print(Data)
  67.            
  68.         end
  69.        
  70.     elseif File == "status" then
  71.        
  72.         file = fs.open("/.Status.st", "w")
  73.         file.write(Status)
  74.         file.close()
  75.        
  76.         SaveFile("log", "Status Saved: "..Status, true)
  77.        
  78.     elseif File == "locations" then
  79.        
  80.         local Data = {Sand = Sand, Water = Water, Mine = Mine, Lava = T:getLava()}
  81.        
  82.         file = fs.open("/.Locations.lo", "w")
  83.         file.write(Pack(Data))
  84.         file.close()
  85.        
  86.         SaveFile("log", "Locations Saved", true)
  87.        
  88.     elseif File == "chests" then
  89.        
  90.         file = fs.open("/.Chests.ch", "w")
  91.         file.write(Pack(Chests))
  92.         file.close()
  93.        
  94.         SaveFile("log", "Locations Saved", true)
  95.        
  96.     end
  97.    
  98. end
  99.  
  100. SaveFile("log", "Starting...", true)
  101.  
  102. if not System.getComputerLabel() then
  103.     local id = System.getComputerID()
  104.     local name = "MineBot"
  105.     System.setComputerLabel(name)
  106.     local test = tonumber(string.sub (name, string.len(name), string.len(name)))
  107.     if type(test) ~= "number" then
  108.         name = name.." ID: "..id
  109.         System.setComputerLabel(name)
  110.     end
  111.     SaveFile("log", "Setting Computer Label to: "..name, true)
  112.     SaveFile("log", "Computer Label: "..name, true)
  113.     print(System.getComputerLabel())
  114. else
  115.     local name = System.getComputerLabel()
  116.     local id = System.getComputerID()
  117.     local test = tonumber(string.sub (name, string.len(name) , string.len(name)))
  118.     if type(test) ~= "number" then
  119.         SaveFile("log", "Add Number to Computer Label: "..name, true)
  120.         name = name.." ID: "..id
  121.         SaveFile("log", "Setting Computer Label to: "..name, true)
  122.         System.setComputerLabel(name)
  123.     end
  124.     SaveFile("log", "Computer Label: "..name, true)
  125.     print(System.getComputerLabel())
  126. end
  127.  
  128. function Turtle()
  129.    
  130.     clsTurtle = turtle -- the table representing the class, which will double as the metatable for any instances
  131.     clsTurtle.__index = clsTurtle -- failed table lookups on the instances should fallback to the class table, to get methods
  132.  
  133.     local self = setmetatable({}, clsTurtle)
  134.    
  135.     self.X = 0
  136.     self.Y = 0
  137.     self.Z = 0
  138.     self.R = 1
  139.     self.HomeX = 0
  140.     self.HomeY = 0
  141.     self.HomeZ = 0
  142.     self.HomeR = 1
  143.     self.Lava = false
  144.     self.Directions = {"North","East","South","West"}
  145.     self.zDiff = {-1, 0, 1, 0} -- Differents between north and south on z ax
  146.     self.xDiff = {0, 1, 0, -1} -- Differents between east and west om x ax
  147.    
  148.     function clsTurtle.getX(self) return self.X end
  149.     function clsTurtle.getY(self) return self.Y end
  150.     function clsTurtle.getZ(self) return self.Z end
  151.     function clsTurtle.getR(self) return self.R end
  152.     function clsTurtle.getHomeX(self) return self.HomeX end
  153.     function clsTurtle.getHomeY(self) return self.HomeY end
  154.     function clsTurtle.getHomeZ(self) return self.HomeZ end
  155.     function clsTurtle.getHomeR(self) return self.HomeR end
  156.     function clsTurtle.getLava(self) return self.Lava end
  157.    
  158.     function clsTurtle.setX(self, newVal) self.X = newVal end
  159.     function clsTurtle.setY(self, newVal) self.Y = newVal end
  160.     function clsTurtle.setZ(self, newVal) self.Z = newVal end
  161.     function clsTurtle.setR(self, newVal) self.R = newVal end
  162.     function clsTurtle.setHomeX(self, newVal) self.HomeX = newVal end
  163.     function clsTurtle.setHomeY(self, newVal) self.HomeY = newVal end
  164.     function clsTurtle.setHomeZ(self, newVal) self.HomeZ = newVal end
  165.     function clsTurtle.setHomeR(self, newVal) self.HomeR = newVal end
  166.     function clsTurtle.setLava(self, newVal) self.Lava = newVal end
  167.    
  168.    
  169.     function clsTurtle.Add(self, to, value)
  170.        
  171.         to = to + value
  172.         return to
  173.        
  174.     end
  175.    
  176.     function clsTurtle.Sub(self, to, value)
  177.        
  178.         to = to - value
  179.         return to
  180.        
  181.     end
  182.    
  183.     function clsTurtle.emptyInv(self)
  184.        
  185.         for i = 1, 2 do
  186.             clsTurtle.Forward(self)
  187.         end
  188.        
  189.         SaveFile("log", "Dropping items", true)
  190.        
  191.         for i = 1, 16 do
  192.             if clsTurtle.getItemDetail(i) ~= nil and not(string.find(clsTurtle.getItemDetail(i).name, "chest")) then
  193.                 clsTurtle.select(i)
  194.                 clsTurtle.dropDown()
  195.             end
  196.         end
  197.        
  198.         for i = 1, 15 do
  199.             if clsTurtle.getItemDetail(i) ~= nil and string.find(clsTurtle.getItemDetail(i).name, "chest") then
  200.                 clsTurtle.select(i)
  201.                 clsTurtle.transferTo(chestSlot, 1)
  202.             end
  203.         end
  204.        
  205.         for i = 1, 15 do
  206.             clsTurtle.select(i)
  207.             clsTurtle.dropDown()
  208.         end
  209.        
  210.         for i = 1, 2 do
  211.             clsTurtle.Back(self)
  212.         end
  213.        
  214.     end
  215.    
  216.     function clsTurtle.findChest(self, name)
  217.        
  218.         for i = 1, #Chests do
  219.            
  220.             if Chests[i].name == name then
  221.                
  222.                 return i
  223.                
  224.             end
  225.            
  226.         end
  227.        
  228.         return false
  229.        
  230.     end
  231.    
  232.     function clsTurtle.checkUp(self)
  233.        
  234.         local succes, Detials = clsTurtle.inspectUp()
  235.        
  236.         if succes then
  237.            
  238.             clsTurtle.digUp()
  239.             clsTurtle.Up(self)
  240.             clsTurtle.checkUp(self)
  241.             clsTurtle.Down(self)
  242.            
  243.         end
  244.        
  245.     end
  246.    
  247.     function clsTurtle.Refuel(self)
  248.        
  249.         if clsTurtle.getFuelLevel() < 1000 then
  250.            
  251.             local filled = {}
  252.            
  253.             local number = clsTurtle.findChest(self, "coal")
  254.            
  255.             if number then
  256.                
  257.                 clsTurtle.GoTo(self, Chests[number])
  258.                
  259.                 clsTurtle.select(1)
  260.                
  261.                 while clsTurtle.suckDown() do end
  262.                
  263.                 local count1, slots1 = clsTurtle.LookInvItems(self, "minecraft:coal", false)
  264.                
  265.                 if #slots1 > 0 then
  266.                    
  267.                     for a = 1, 16 do
  268.                        
  269.                         details = clsTurtle.getItemDetail(a)
  270.                        
  271.                         if details and details.name ~= "minecraft:coal" then
  272.                            
  273.                             clsTurtle.select(a)
  274.                             clsTurtle.dropDown()
  275.                            
  276.                         end
  277.                        
  278.                     end
  279.                    
  280.                     if count1 >= 9 then
  281.                        
  282.                         local T1 = 16
  283.                        
  284.                         for b = 1, #slots1 do
  285.                            
  286.                             clsTurtle.select(slots1[b])
  287.                             clsTurtle.transferTo(T1,64)
  288.                             T1 = clsTurtle.Sub(self, T1, 1)
  289.                            
  290.                         end
  291.                        
  292.                         count1, slots1 = clsTurtle.LookInvItems(self, "minecraft:coal", false)
  293.                        
  294.                         local C = {}
  295.                        
  296.                         for b = 1, #slots1 do
  297.                            
  298.                             C[b] = {}
  299.                             C[b].slot = slots1[b]
  300.                             C[b].count = clsTurtle.getItemCount(C[b].slot)
  301.                            
  302.                         end
  303.                        
  304.                         for b = 1, #C do
  305.                            
  306.                             clsTurtle.select(C[b].slot)
  307.                            
  308.                             if C[b].count >= 9 then
  309.                                
  310.                                 N = math.floor(C[b].count / 9)
  311.                                
  312.                                 for z = 1,3 do clsTurtle.transferTo(z,N) end
  313.                                 for z = 5,7 do clsTurtle.transferTo(z,N) end
  314.                                 for z = 9,11 do clsTurtle.transferTo(z,N) end
  315.                                
  316.                             end
  317.                            
  318.                             clsTurtle.dropDown()
  319.                            
  320.                         end
  321.                        
  322.                         clsTurtle.craft()
  323.                        
  324.                     else
  325.                        
  326.                         for a = 1, 16 do
  327.                            
  328.                             details = clsTurtle.getItemDetail(a)
  329.                            
  330.                             if details and details.name == "minecraft:coal" then
  331.                                
  332.                                 clsTurtle.select(a)
  333.                                 clsTurtle.dropDown()
  334.                                
  335.                             end
  336.                            
  337.                         end
  338.                        
  339.                     end
  340.                    
  341.                 end
  342.                
  343.                 clsTurtle.select(1)
  344.                
  345.                 while clsTurtle.suckDown() do end
  346.                
  347.                 local count1, slots1 = clsTurtle.LookInvItems(self, "minecraft:charcoal", false)
  348.                
  349.                 if #slots1 > 0 then
  350.                    
  351.                     for a = 1, 16 do
  352.                        
  353.                         details = clsTurtle.getItemDetail(a)
  354.                        
  355.                         if details and details.name ~= "minecraft:charcoal" then
  356.                            
  357.                             clsTurtle.select(a)
  358.                             clsTurtle.dropDown()
  359.                            
  360.                         end
  361.                        
  362.                     end
  363.                    
  364.                     if count1 >= 9 then
  365.                        
  366.                         local T1 = 16
  367.                        
  368.                         for b = 1, #slots1 do
  369.                            
  370.                             clsTurtle.select(slots1[b])
  371.                             clsTurtle.transferTo(T1,64)
  372.                             T1 = clsTurtle.Sub(self, T1, 1)
  373.                            
  374.                         end
  375.                        
  376.                         count1, slots1 = clsTurtle.LookInvItems(self, "minecraft:charcoal", false)
  377.                        
  378.                         local C = {}
  379.                        
  380.                         for b = 1, #slots1 do
  381.                            
  382.                             C[b] = {}
  383.                             C[b].slot = slots1[b]
  384.                             C[b].count = clsTurtle.getItemCount(C[b].slot)
  385.                            
  386.                         end
  387.                        
  388.                         for b = 1, #C do
  389.                            
  390.                             clsTurtle.select(C[b].slot)
  391.                            
  392.                             if C[b].count >= 9 then
  393.                                
  394.                                 N = math.floor(C[b].count / 9)
  395.                                
  396.                                 for z = 1,3 do clsTurtle.transferTo(z,N) end
  397.                                 for z = 5,7 do clsTurtle.transferTo(z,N) end
  398.                                 for z = 9,11 do clsTurtle.transferTo(z,N) end
  399.                                
  400.                             end
  401.                            
  402.                             clsTurtle.dropDown()
  403.                            
  404.                         end
  405.                        
  406.                         clsTurtle.craft()
  407.                        
  408.                     else
  409.                        
  410.                         for a = 1, 16 do
  411.                            
  412.                             details = clsTurtle.getItemDetail(a)
  413.                            
  414.                             if details and details.name == "minecraft:charcoal" then
  415.                                
  416.                                 clsTurtle.select(a)
  417.                                 clsTurtle.dropDown()
  418.                                
  419.                             end
  420.                            
  421.                         end
  422.                        
  423.                     end
  424.                    
  425.                 end
  426.                
  427.                 clsTurtle.select(1)
  428.                
  429.                 while clsTurtle.suckDown() do end
  430.                
  431.                 for i = 1, 16 do
  432.                    
  433.                     local details = clsTurtle.getItemDetail(i)
  434.                    
  435.                     if details and details.name ~= Tools[4] and not(string.find(details.name, "chest")) and not(string.find(details.name, "sapling")) then
  436.                        
  437.                         clsTurtle.select(i)
  438.                         local Fill = clsTurtle.refuel()
  439.                         table.insert(filled, Fill)
  440.                        
  441.                     end
  442.                    
  443.                 end
  444.                
  445.                 clsTurtle.select(1)
  446.                
  447.                 while clsTurtle.suckDown() do end
  448.                
  449.                 for i = 1, 16 do
  450.                    
  451.                     local details = clsTurtle.getItemDetail(i)
  452.                    
  453.                     if details and string.find(details.name, "chest") then
  454.                        
  455.                         clsTurtle.select(i)
  456.                         clsTurtle.transferTo(chestSlot, 1)
  457.                        
  458.                     elseif details and string.find(details.name, "bucket") then
  459.                        
  460.                         clsTurtle.select(i)
  461.                         clsTurtle.transferTo(bucketSlot, 1)
  462.                        
  463.                     elseif details and string.find(details.name, "modem") then
  464.                        
  465.                         clsTurtle.select(i)
  466.                         clsTurtle.transferTo(modemSlot, 1)
  467.                        
  468.                     elseif details and details.name ~= Tools[4] and not(string.find(details.name, "modem")) and not(string.find(details.name, "chest")) and not(string.find(details.name, "bucket")) then
  469.                        
  470.                         clsTurtle.select(i)
  471.                         clsTurtle.dropDown()
  472.                        
  473.                     end
  474.                    
  475.                 end
  476.                
  477.                 clsTurtle.select(1)
  478.                
  479.                 clsTurtle.GoTo(self, clsTurtle.getHomeX(self), clsTurtle.getHomeY(self), clsTurtle.getHomeZ(self))
  480.                 clsTurtle.TurnDirection(self, clsTurtle.getHomeR(self))
  481.                
  482.             end
  483.            
  484.             local F1 = {}
  485.             F1[1] = false
  486.            
  487.             for i = 1, #filled do
  488.                
  489.                 if filled[i] then
  490.                    
  491.                     F1[1] = true
  492.                    
  493.                 end
  494.                
  495.             end
  496.            
  497.             if not(F1[1]) then
  498.                
  499.                 filled = {}
  500.                
  501.                 local number = clsTurtle.findChest(self, "wood")
  502.                
  503.                 if number then
  504.                    
  505.                     clsTurtle.GoTo(self, Chests[number])
  506.                    
  507.                     clsTurtle.select(1)
  508.                    
  509.                     while clsTurtle.suckDown() do end
  510.                    
  511.                     for i = 1, 16 do
  512.                        
  513.                         local details = clsTurtle.getItemDetail(i)
  514.                        
  515.                         if details and details.name ~= Tools[4] and not(string.find(details.name, "chest")) and not(string.find(details.name, "sapling")) then
  516.                            
  517.                             clsTurtle.select(i)
  518.                             local Fill = clsTurtle.refuel()
  519.                             table.insert(filled, Fill)
  520.                            
  521.                         end
  522.                        
  523.                     end
  524.                    
  525.                     while clsTurtle.suckDown() do end
  526.                    
  527.                     for i = 1, 16 do
  528.                        
  529.                         local details = clsTurtle.getItemDetail(i)
  530.                        
  531.                         if details and details.name ~= Tools[4] and not(string.find(details.name, "chest")) and not(string.find(details.name, "bucket")) then
  532.                            
  533.                             clsTurtle.select(i)
  534.                             clsTurtle.dropDown()
  535.                            
  536.                         elseif details and string.find(details.name, "chest") then
  537.                            
  538.                             clsTurtle.select(i)
  539.                             clsTurtle.transferTo(chestSlot, 1)
  540.                            
  541.                         elseif details and string.find(details.name, "bucket") then
  542.                            
  543.                             clsTurtle.select(i)
  544.                             clsTurtle.transferTo(bucketSlot, 1)
  545.                            
  546.                         elseif details and string.find(details.name, "modem") then
  547.                            
  548.                             clsTurtle.select(i)
  549.                             clsTurtle.transferTo(modemSlot, 1)
  550.                            
  551.                         end
  552.                        
  553.                     end
  554.                    
  555.                 end
  556.                
  557.                 clsTurtle.select(1)
  558.                
  559.                 clsTurtle.GoTo(self, clsTurtle.getHomeX(self), clsTurtle.getHomeY(self), clsTurtle.getHomeZ(self))
  560.                 clsTurtle.TurnDirection(self, clsTurtle.getHomeR(self))
  561.                
  562.             end
  563.            
  564.             F1[2] = false
  565.            
  566.             for i = 1, #filled do
  567.                
  568.                 if filled[i] then
  569.                    
  570.                     F1[2] = true
  571.                    
  572.                 end
  573.                
  574.             end
  575.            
  576.             if not(F1[2]) and Status > 7 then
  577.                
  578.                 filled = {}
  579.                
  580.                 HarvestTreeFarm()
  581.                
  582.                 local number = clsTurtle.findChest(self, "wood")
  583.                
  584.                 if number then
  585.                    
  586.                     clsTurtle.GoTo(self, Chests[number])
  587.                    
  588.                     clsTurtle.select(1)
  589.                    
  590.                     while clsTurtle.suckDown() do end
  591.                    
  592.                     for i = 1, 16 do
  593.                        
  594.                         local details = clsTurtle.getItemDetail(i)
  595.                        
  596.                         if details and details.name ~= Tools[4] and not(string.find(details.name, "chest")) and not(string.find(details.name, "sapling")) then
  597.                            
  598.                             clsTurtle.select(i)
  599.                             local Fill = clsTurtle.refuel()
  600.                             table.insert(filled, Fill)
  601.                            
  602.                         end
  603.                        
  604.                     end
  605.                    
  606.                     while clsTurtle.suckDown() do end
  607.                    
  608.                     for i = 1, 16 do
  609.                        
  610.                         local details = clsTurtle.getItemDetail(i)
  611.                        
  612.                         if details and details.name ~= Tools[4] and not(string.find(details.name, "chest")) and not(string.find(details.name, "bucket")) then
  613.                            
  614.                             clsTurtle.select(i)
  615.                             clsTurtle.dropDown()
  616.                            
  617.                         elseif details and string.find(details.name, "chest") then
  618.                            
  619.                             clsTurtle.select(i)
  620.                             clsTurtle.transferTo(chestSlot, 1)
  621.                            
  622.                         elseif details and string.find(details.name, "bucket") then
  623.                            
  624.                             clsTurtle.select(i)
  625.                             clsTurtle.transferTo(bucketSlot, 1)
  626.                            
  627.                         elseif details and string.find(details.name, "modem") then
  628.                            
  629.                             clsTurtle.select(i)
  630.                             clsTurtle.transferTo(modemSlot, 1)
  631.                            
  632.                         end
  633.                        
  634.                     end
  635.                    
  636.                 end
  637.                
  638.                 clsTurtle.select(1)
  639.                
  640.                 clsTurtle.GoTo(self, clsTurtle.getHomeX(self), clsTurtle.getHomeY(self), clsTurtle.getHomeZ(self))
  641.                 clsTurtle.TurnDirection(self, clsTurtle.getHomeR(self))
  642.                
  643.             end
  644.            
  645.             F1[3] = false
  646.            
  647.             for i = 1, #filled do
  648.                
  649.                 if filled[i] then
  650.                    
  651.                     F1[3] = true
  652.                    
  653.                 end
  654.                
  655.             end
  656.            
  657.             local F = false
  658.            
  659.             for i = 1, #F1 do
  660.                
  661.                 if F1[i] then
  662.                    
  663.                     F = true
  664.                    
  665.                 end
  666.                
  667.             end
  668.            
  669.             return F
  670.            
  671.         else
  672.            
  673.             return false
  674.            
  675.         end
  676.        
  677.     end
  678.  
  679.     function clsTurtle.Forward(self)
  680.        
  681.         local Moved = clsTurtle.forward()
  682.        
  683.         if Moved then
  684.            
  685.             clsTurtle.setX(self, clsTurtle.getX(self) + self.xDiff[clsTurtle.getR(self)])
  686.          
  687.             clsTurtle.setZ(self, clsTurtle.getZ(self) + self.zDiff[clsTurtle.getR(self)])
  688.            
  689.         end
  690.        
  691.         return Moved
  692.        
  693.     end
  694.  
  695.     function clsTurtle.Back(self)
  696.        
  697.         local Moved = clsTurtle.back()
  698.        
  699.         if Moved then
  700.            
  701.             clsTurtle.setX(self, clsTurtle.getX(self) - self.xDiff[clsTurtle.getR(self)])
  702.          
  703.             clsTurtle.setZ(self, clsTurtle.getZ(self) - self.zDiff[clsTurtle.getR(self)])
  704.            
  705.         end
  706.        
  707.         return Moved
  708.        
  709.     end
  710.  
  711.     function clsTurtle.Up(self)
  712.        
  713.         local Moved = clsTurtle.up()
  714.        
  715.         if Moved then
  716.            
  717.             clsTurtle.setY(self, clsTurtle.getY(self) + 1)
  718.            
  719.         end
  720.        
  721.         return Moved
  722.        
  723.     end
  724.  
  725.     function clsTurtle.Down(self)
  726.        
  727.         local Moved = clsTurtle.down()
  728.        
  729.         if Moved then
  730.            
  731.             clsTurtle.setY(self, clsTurtle.getY(self) - 1)
  732.            
  733.         end
  734.        
  735.         return Moved
  736.        
  737.     end
  738.  
  739.     function clsTurtle.TurnDirection(self, O)
  740.        
  741.         SaveFile("log", "turn to: "..O.." = "..self.Directions[O], true)
  742.        
  743.         while clsTurtle.getR(self) ~= O do
  744.            
  745.             clsTurtle.TurnLeft(self)
  746.            
  747.         end
  748.        
  749.     end
  750.  
  751.     function clsTurtle.TurnLeft(self)
  752.        
  753.         local Ro = (clsTurtle.getR(self) - 1)
  754.      
  755.         Ro = (Ro - 1) % 4
  756.      
  757.         clsTurtle.setR(self, (Ro + 1))
  758.        
  759.         clsTurtle.turnLeft()
  760.        
  761.     end
  762.  
  763.     function clsTurtle.TurnRight(self)
  764.        
  765.         local Ro = (clsTurtle.getR(self) - 1)
  766.      
  767.         Ro = (Ro + 1) % 4
  768.      
  769.         clsTurtle.setR(self, (Ro + 1))
  770.        
  771.         clsTurtle.turnRight()
  772.        
  773.     end
  774.    
  775.     function clsTurtle.GoTo(self, GX, GY, GZ)
  776.        
  777.         if type(GX) == "table" then
  778.            
  779.             GZ = GX.Z
  780.             GY = GX.Y
  781.             GX = GX.X
  782.            
  783.         end
  784.        
  785.         SaveFile("log", "GoTo: X: "..GX.." Y: "..GY.." Z: "..GZ, true)
  786.        
  787.         if clsTurtle.getFuelLevel() < 500 then
  788.            
  789.             clsTurtle.Refuel(self)
  790.            
  791.         end
  792.        
  793.         while clsTurtle.getY(self) < GY and not(clsTurtle.detectUp()) do
  794.            
  795.             clsTurtle.Up(self)
  796.            
  797.         end
  798.        
  799.         while clsTurtle.getY(self) > GY and not(clsTurtle.detectDown()) do
  800.            
  801.             clsTurtle.Down(self)
  802.            
  803.         end
  804.        
  805.         if clsTurtle.getX(self) < GX then
  806.            
  807.             clsTurtle.TurnDirection(self, 2)
  808.            
  809.             while clsTurtle.getX(self) < GX do
  810.                
  811.                 if not(clsTurtle.Forward(self)) then break end
  812.                
  813.             end
  814.            
  815.         end
  816.        
  817.         if clsTurtle.getX(self) > GX then
  818.            
  819.             clsTurtle.TurnDirection(self, 4)
  820.            
  821.             while clsTurtle.getX(self) > GX do
  822.                
  823.                 if not(clsTurtle.Forward(self)) then break end
  824.                
  825.             end
  826.            
  827.         end
  828.        
  829.         if clsTurtle.getZ(self) < GZ then
  830.            
  831.             clsTurtle.TurnDirection(self, 3)
  832.            
  833.             while clsTurtle.getZ(self) < GZ do
  834.                
  835.                 if not(clsTurtle.Forward(self)) then break end
  836.                
  837.             end
  838.            
  839.         end
  840.        
  841.         if clsTurtle.getZ(self) > GZ then
  842.            
  843.             clsTurtle.TurnDirection(self, 1)
  844.            
  845.             while clsTurtle.getZ(self) > GZ do
  846.                
  847.                 if not(clsTurtle.Forward(self)) then break end
  848.                
  849.             end
  850.            
  851.         end
  852.        
  853.         while clsTurtle.getY(self) < GY and not(clsTurtle.detectUp()) do
  854.            
  855.             clsTurtle.Up(self)
  856.            
  857.         end
  858.        
  859.         while clsTurtle.getY(self) > GY and not(clsTurtle.detectDown()) do
  860.            
  861.             clsTurtle.Down(self)
  862.            
  863.         end
  864.        
  865.     end
  866.  
  867.     function clsTurtle.GoHome(self)
  868.        
  869.         SaveFile("log", "Going home", true)
  870.        
  871.         while clsTurtle.getY(self) < 100 do
  872.            
  873.             while clsTurtle.detectUp() do
  874.                
  875.                 while clsTurtle.detect() do
  876.                    
  877.                     clsTurtle.TurnLeft(self)
  878.                    
  879.                 end
  880.                
  881.                 clsTurtle.Forward(self)
  882.                
  883.             end
  884.            
  885.             clsTurtle.Up(self)
  886.            
  887.         end
  888.        
  889.         while clsTurtle.getY(self) > 100 do
  890.            
  891.             clsTurtle.Down(self)
  892.            
  893.         end
  894.        
  895.         if clsTurtle.getX(self) < clsTurtle.getHomeX(self) then
  896.            
  897.             clsTurtle.TurnDirection(self, 2)
  898.            
  899.             while clsTurtle.getX(self) < clsTurtle.getHomeX(self) do
  900.                
  901.                 clsTurtle.Forward(self)
  902.                
  903.             end
  904.            
  905.         end
  906.        
  907.         if clsTurtle.getX(self) > clsTurtle.getHomeX(self) then
  908.            
  909.             clsTurtle.TurnDirection(self, 4)
  910.            
  911.             while clsTurtle.getX(self) > clsTurtle.getHomeX(self) do
  912.                
  913.                 clsTurtle.Forward(self)
  914.                
  915.             end
  916.            
  917.         end
  918.        
  919.         if clsTurtle.getZ(self) < clsTurtle.getHomeZ(self) then
  920.            
  921.             clsTurtle.TurnDirection(self, 3)
  922.            
  923.             while clsTurtle.getZ(self) < clsTurtle.getHomeZ(self) do
  924.                
  925.                 clsTurtle.Forward(self)
  926.                
  927.             end
  928.            
  929.         end
  930.        
  931.         if clsTurtle.getZ(self) > clsTurtle.getHomeZ(self) then
  932.            
  933.             clsTurtle.TurnDirection(self, 1)
  934.            
  935.             while clsTurtle.getZ(self) > clsTurtle.getHomeZ(self) do
  936.                
  937.                 clsTurtle.Forward(self)
  938.                
  939.             end
  940.            
  941.         end
  942.        
  943.         while clsTurtle.getY(self) < clsTurtle.getHomeY(self) do
  944.            
  945.             clsTurtle.Up(self)
  946.            
  947.         end
  948.        
  949.         while clsTurtle.getY(self) > clsTurtle.getHomeY(self) do
  950.            
  951.             clsTurtle.Down(self)
  952.            
  953.         end
  954.        
  955.         clsTurtle.TurnDirection(self, clsTurtle.getHomeR(self))
  956.        
  957.     end
  958.  
  959.  
  960.     function clsTurtle.Craft(self, tocraft, countt, resource)
  961.        
  962.         local count, slots = clsTurtle.LookInvItems(self, resource, true)
  963.        
  964.         for i = 1, 16 do
  965.            
  966.             local found = false
  967.            
  968.             for j = 1, #slots do
  969.                
  970.                 if i == slots[j] then
  971.                    
  972.                     found = true
  973.                    
  974.                 end
  975.                
  976.             end
  977.            
  978.             if not(found) then
  979.                
  980.                 clsTurtle.select(i)
  981.                 clsTurtle.dropDown()
  982.                
  983.             end
  984.            
  985.         end
  986.        
  987.         if #slots >= 2 then
  988.            
  989.             for i = 2, #slots do
  990.                
  991.                 clsTurtle.select(slots[i])
  992.                 clsTurtle.dropDown()
  993.                
  994.             end
  995.            
  996.         end
  997.        
  998.         clsTurtle.select(slots[1])
  999.         clsTurtle.transferTo(4)
  1000.         clsTurtle.select(4)
  1001.        
  1002.         if tocraft == "planks" then
  1003.            
  1004.             local details = clsTurtle.getItemDetail(4)
  1005.            
  1006.             if details.count >= math.ceil(countt / 4) then
  1007.                
  1008.                 local a = math.ceil(countt / 4)
  1009.                
  1010.                 clsTurtle.transferTo(1, a)
  1011.                 clsTurtle.dropDown()
  1012.                 clsTurtle.craft(a)
  1013.                
  1014.             end
  1015.            
  1016.         elseif tocraft == "bone_meal" then
  1017.            
  1018.             local details = clsTurtle.getItemDetail(4)
  1019.            
  1020.             if details.count >= math.ceil(countt / 3) then
  1021.                
  1022.                 local a = math.ceil(countt / 3)
  1023.                
  1024.                 clsTurtle.transferTo(1, a)
  1025.                 clsTurtle.dropDown()
  1026.                 clsTurtle.craft(a)
  1027.                
  1028.             end
  1029.            
  1030.         elseif tocraft == "white_dye" then
  1031.            
  1032.             local details = clsTurtle.getItemDetail(4)
  1033.            
  1034.             if details.count >= countt then
  1035.                
  1036.                 clsTurtle.transferTo(1, countt)
  1037.                 clsTurtle.dropDown()
  1038.                 clsTurtle.craft(countt)
  1039.                
  1040.             end
  1041.            
  1042.         elseif tocraft == "stick" then
  1043.            
  1044.             local details = clsTurtle.getItemDetail(4)
  1045.            
  1046.             if details.count >= math.ceil(countt / 4) * 2 then
  1047.                
  1048.                 local a = math.ceil(countt / 4)
  1049.                
  1050.                 clsTurtle.transferTo(1, a)
  1051.                 clsTurtle.transferTo(5, a)
  1052.                 clsTurtle.dropDown()
  1053.                 clsTurtle.craft(a)
  1054.                
  1055.             end
  1056.            
  1057.         elseif tocraft == "paper" then
  1058.            
  1059.             local details = clsTurtle.getItemDetail(4)
  1060.            
  1061.             if details.count >= math.ceil(countt) then
  1062.                
  1063.                 local a = math.ceil(countt / 3)
  1064.                
  1065.                 clsTurtle.transferTo(1, a)
  1066.                 clsTurtle.transferTo(2, a)
  1067.                 clsTurtle.transferTo(3, a)
  1068.                 clsTurtle.dropDown()
  1069.                 clsTurtle.craft(a)
  1070.                
  1071.             end
  1072.            
  1073.         elseif tocraft == "chest" then
  1074.            
  1075.             local details = clsTurtle.getItemDetail(4)
  1076.            
  1077.             if details.count >= countt * 8 then
  1078.                
  1079.                 clsTurtle.transferTo(1, countt)
  1080.                 clsTurtle.transferTo(2, countt)
  1081.                 clsTurtle.transferTo(3, countt)
  1082.                 clsTurtle.transferTo(5, countt)
  1083.                 clsTurtle.transferTo(7, countt)
  1084.                 clsTurtle.transferTo(9, countt)
  1085.                 clsTurtle.transferTo(10, countt)
  1086.                 clsTurtle.transferTo(11, countt)
  1087.                 clsTurtle.dropDown()
  1088.                 clsTurtle.craft(countt)
  1089.                
  1090.             end
  1091.            
  1092.         elseif tocraft == "furnace" then
  1093.            
  1094.             local details = clsTurtle.getItemDetail(4)
  1095.            
  1096.             if details.count >= countt * 8 then
  1097.                
  1098.                 clsTurtle.transferTo(1, countt)
  1099.                 clsTurtle.transferTo(2, countt)
  1100.                 clsTurtle.transferTo(3, countt)
  1101.                 clsTurtle.transferTo(5, countt)
  1102.                 clsTurtle.transferTo(7, countt)
  1103.                 clsTurtle.transferTo(9, countt)
  1104.                 clsTurtle.transferTo(10, countt)
  1105.                 clsTurtle.transferTo(11, countt)
  1106.                 clsTurtle.dropDown()
  1107.                 clsTurtle.craft(countt)
  1108.                
  1109.             end
  1110.            
  1111.         elseif tocraft == "bucket" then
  1112.            
  1113.             local details = clsTurtle.getItemDetail(4)
  1114.            
  1115.             if details.count >= countt * 3 then
  1116.                
  1117.                 clsTurtle.transferTo(1, countt)
  1118.                 clsTurtle.transferTo(3, countt)
  1119.                 clsTurtle.transferTo(6, countt)
  1120.                 clsTurtle.dropDown()
  1121.                 clsTurtle.craft(countt)
  1122.                
  1123.             end
  1124.            
  1125.         elseif tocraft == "ladder" then
  1126.            
  1127.             local details = clsTurtle.getItemDetail(4)
  1128.             local N = math.ceil(countt / 3)
  1129.            
  1130.             if details.count >= math.ceil(N * 7) then
  1131.                
  1132.                 clsTurtle.transferTo(1, N)
  1133.                 clsTurtle.transferTo(3, N)
  1134.                 clsTurtle.transferTo(5, N)
  1135.                 clsTurtle.transferTo(6, N)
  1136.                 clsTurtle.transferTo(7, N)
  1137.                 clsTurtle.transferTo(9, N)
  1138.                 clsTurtle.transferTo(11, N)
  1139.                 clsTurtle.dropDown()
  1140.                 clsTurtle.craft(N)
  1141.                
  1142.             end
  1143.            
  1144.         end
  1145.        
  1146.     end
  1147.  
  1148.     function clsTurtle.LookInvItems(self, name, Find)
  1149.        
  1150.         local Count, Slots = 0 , {}
  1151.        
  1152.         for i = 1, 16 do
  1153.            
  1154.             local Details = clsTurtle.getItemDetail(i)
  1155.            
  1156.             if Details then
  1157.                
  1158.                 if Find == true then
  1159.                    
  1160.                     if string.find(Details.name, name) then
  1161.                        
  1162.                         Count = Count + Details.count
  1163.                         table.insert(Slots, i)
  1164.                        
  1165.                     end
  1166.                    
  1167.                 elseif Find == false then
  1168.                    
  1169.                     if Details.name == name then
  1170.                        
  1171.                         Count = Count + Details.count
  1172.                         table.insert(Slots, i)
  1173.                        
  1174.                     end
  1175.                    
  1176.                 end
  1177.                
  1178.             end
  1179.            
  1180.         end
  1181.        
  1182.         return Count, Slots
  1183.        
  1184.     end
  1185.    
  1186.     function clsTurtle.SortInvItems(self, number)
  1187.        
  1188.         local keep = {}
  1189.        
  1190.         if Status <= 4 then
  1191.             keep = {"coal","sand","redstone","dirt","torch","diamond","ore","iron","gold","log","sugar_cane","lapis","emerald","chest","modem","bucket","cobblestone","bone","crafting_table","sapling","seed"}
  1192.         else
  1193.             keep = {"coal","sand","redstone","torch","diamond","ore","iron","gold","log","sugar_cane","lapis","emerald","chest","modem","bucket","cobblestone","bone","crafting_table","sapling","seed"}
  1194.         end
  1195.        
  1196.         for I = 1, 16 do
  1197.            
  1198.             local details = clsTurtle.getItemDetail(I)
  1199.            
  1200.             if details then
  1201.                
  1202.                 local found = false
  1203.                
  1204.                 for A = 1, #keep do
  1205.                
  1206.                     if string.find(details.name, keep[A]) then
  1207.                        
  1208.                         found = true
  1209.                        
  1210.                         local count, slots = clsTurtle.LookInvItems(self, details.name, false)
  1211.                         local b = 1
  1212.                        
  1213.                         if #slots > 1 then
  1214.                            
  1215.                             for i = 2, #slots do
  1216.                                
  1217.                                 if number == 1 then
  1218.                                    
  1219.                                     clsTurtle.select(slots[i])
  1220.                                     clsTurtle.transferTo(slots[b], 64)
  1221.                                    
  1222.                                     while clsTurtle.getItemCount(slots[b]) == 64 and b < 16 do
  1223.                                         if b < #slots then
  1224.                                             b = clsTurtle.Add(self, b, 1)
  1225.                                         end
  1226.                                         clsTurtle.transferTo(slots[b], 64)
  1227.                                     end
  1228.                                    
  1229.                                 elseif number == 2 then
  1230.                                    
  1231.                                     if string.find(details.name, "cobblestone") then
  1232.                                        
  1233.                                         clsTurtle.select(slots[i])
  1234.                                         clsTurtle.transferTo(slots[1], 64)
  1235.                                         clsTurtle.drop()
  1236.                                        
  1237.                                     else
  1238.                                        
  1239.                                         clsTurtle.select(slots[i])
  1240.                                         clsTurtle.transferTo(slots[b], 64)
  1241.                                        
  1242.                                         while clsTurtle.getItemCount(slots[b]) == 64 and b < 16 do
  1243.                                             if b < #slots then
  1244.                                                 b = clsTurtle.Add(self, b, 1)
  1245.                                             end
  1246.                                             clsTurtle.transferTo(slots[b], 64)
  1247.                                         end
  1248.                                        
  1249.                                     end
  1250.                                    
  1251.                                 elseif number == 3 then
  1252.                                    
  1253.                                     clsTurtle.select(slots[i])
  1254.                                     clsTurtle.transferTo(slots[1], 64)
  1255.                                     clsTurtle.drop()
  1256.                                    
  1257.                                 end
  1258.                                
  1259.                             end
  1260.                            
  1261.                         else
  1262.                            
  1263.                             if string.find(details.name, "modem") and I ~= modemSlot then
  1264.                                
  1265.                                 clsTurtle.select(I)
  1266.                                 clsTurtle.transferTo(modemSlot, 1)
  1267.                                
  1268.                             elseif string.find(details.name, "bucket") and I ~= bucketSlot then
  1269.                                
  1270.                                 clsTurtle.select(I)
  1271.                                 clsTurtle.transferTo(bucketSlot, 1)
  1272.                                
  1273.                             elseif string.find(details.name, "chest") and I ~=  chestSlot then
  1274.                                
  1275.                                 clsTurtle.select(I)
  1276.                                 clsTurtle.transferTo(chestSlot, 1)
  1277.                                
  1278.                             end
  1279.                            
  1280.                         end
  1281.                        
  1282.                     end
  1283.                    
  1284.                 end
  1285.                
  1286.                 if not(found) then
  1287.                     clsTurtle.select(I)
  1288.                     clsTurtle.drop()
  1289.                 end
  1290.                
  1291.             end
  1292.            
  1293.         end
  1294.        
  1295.         clsTurtle.select(1)
  1296.        
  1297.     end
  1298.    
  1299.     function clsTurtle.GetItemFromChest(self, chest, item, count, slot, Find)
  1300.        
  1301.         if Find == nil then
  1302.             Find = true
  1303.         end
  1304.        
  1305.         local number, N
  1306.        
  1307.         if type(chest) == "string"then
  1308.             number = clsTurtle.findChest(self, chest)
  1309.         elseif type(chest) == "number" then
  1310.             number = chest
  1311.         end
  1312.        
  1313.         if number then
  1314.            
  1315.             GetChest()
  1316.             clsTurtle.GoTo(self, Chests[number])
  1317.             clsTurtle.select(chestSlot)
  1318.            
  1319.             local side = "top"
  1320.            
  1321.             if number == 1 then
  1322.                 clsTurtle.place()
  1323.                 side = "front"
  1324.             else
  1325.                 clsTurtle.placeUp()
  1326.                 side = "top"
  1327.             end
  1328.            
  1329.             local chest1 = Per.wrap("bottom")
  1330.            
  1331.             local size1 = chest1.size()
  1332.            
  1333.             local haveitem = false
  1334.            
  1335.             _, slots = clsTurtle.LookInvItems(self, item, Find)
  1336.            
  1337.             local number1 = count
  1338.            
  1339.             if #slots > 0 then
  1340.                
  1341.                 for i = 1, #slots do
  1342.                    
  1343.                     clsTurtle.select(slots[i])
  1344.                     clsTurtle.dropDown()
  1345.                    
  1346.                 end
  1347.                
  1348.             end
  1349.            
  1350.             for i = 1, size1 do
  1351.                
  1352.                 local Details = chest1.getItemDetail(i)
  1353.                
  1354.                 if Details then
  1355.                    
  1356.                     if Find and string.find(Details.name, item) and number1 > 0 then
  1357.                        
  1358.                         if Details.count < number1 then
  1359.                            
  1360.                             chest1.pushItems(side, i, Details.count)
  1361.                             number1 = number1 - Details.count
  1362.                             clsTurtle.select(slot)
  1363.                            
  1364.                             if number == 1 then
  1365.                                 clsTurtle.suck()
  1366.                             else
  1367.                                 clsTurtle.suckUp()
  1368.                             end
  1369.                            
  1370.                         elseif Details.count >= number1 then
  1371.                            
  1372.                             chest1.pushItems(side, i, number1)
  1373.                             number1 = number1 - number1
  1374.                             clsTurtle.select(slot)
  1375.                            
  1376.                             if number == 1 then
  1377.                                 clsTurtle.suck()
  1378.                             else
  1379.                                 clsTurtle.suckUp()
  1380.                             end
  1381.                            
  1382.                         end
  1383.                        
  1384.                     elseif not(Find) and Details.name == item and number1 > 0 then
  1385.                        
  1386.                         if Details.count < number1 then
  1387.                            
  1388.                             chest1.pushItems(side, i, Details.count)
  1389.                             number1 = number1 - Details.count
  1390.                             clsTurtle.select(slot)
  1391.                            
  1392.                             if number == 1 then
  1393.                                 clsTurtle.suck()
  1394.                             else
  1395.                                 clsTurtle.suckUp()
  1396.                             end
  1397.                            
  1398.                         elseif Details.count >= number1 then
  1399.                            
  1400.                             chest1.pushItems(side, i, number1)
  1401.                             number1 = number1 - number1
  1402.                             clsTurtle.select(slot)
  1403.                            
  1404.                             if number == 1 then
  1405.                                 clsTurtle.suck()
  1406.                             else
  1407.                                 clsTurtle.suckUp()
  1408.                             end
  1409.                            
  1410.                         end
  1411.                        
  1412.                     elseif number1 <= 0 then
  1413.                        
  1414.                         break
  1415.                        
  1416.                     end
  1417.                    
  1418.                 end
  1419.                
  1420.             end
  1421.            
  1422.             N = clsTurtle.getItemCount(slot)
  1423.            
  1424.             if N >= count then
  1425.                 haveitem = true
  1426.             end
  1427.            
  1428.             if not(haveitem) then
  1429.                 clsTurtle.dropDown()
  1430.             end
  1431.            
  1432.             clsTurtle.select(chestSlot)
  1433.            
  1434.             if number == 1 then
  1435.                 clsTurtle.dig()
  1436.             else
  1437.                 clsTurtle.digUp()
  1438.             end
  1439.            
  1440.             if not(haveitem) then
  1441.                
  1442.                 SaveFile("log", "Cant find "..item, true)
  1443.                 return false, "Cant find "..item, N
  1444.                
  1445.             else
  1446.                
  1447.                 return true
  1448.                
  1449.             end
  1450.            
  1451.         else
  1452.            
  1453.             SaveFile("log", "Cant find chest for "..item, true)
  1454.             return false, "Cant find chest for "..item
  1455.            
  1456.         end
  1457.        
  1458.     end
  1459.    
  1460.     return self
  1461.    
  1462. end
  1463.  
  1464. local T = Turtle()
  1465.  
  1466. local file = fs.exists("/API/Logo.lua")
  1467.  
  1468. if not(file) then
  1469.  
  1470.     shell.run("pastebin get s3aBGUVr /API/Logo.lua")
  1471.    
  1472.     Monitor[0].clear()
  1473.     Monitor[0].setCursorPos(1,1)
  1474.    
  1475. end
  1476.  
  1477. System.loadAPI("/API/Logo.lua")
  1478.  
  1479. Monitor[0].clear()
  1480.  
  1481. Logo.drawLogo(Monitor[0], "Head", math.floor(w/2)-6, math.floor(h/2)-4)
  1482.  
  1483. Monitor[0].setCursorPos(1, (h-1))
  1484. Monitor[0].clearLine()
  1485. Monitor[0].setBackgroundColor(colors.white)
  1486. Monitor[0].setTextColor(colors.black)
  1487. Monitor[0].setCursorPos(math.floor((w - string.len("Looking for file...")) /2), (h-1))
  1488.  
  1489. SaveFile("log", "Looking for files...", true)
  1490.  
  1491. local file0 = fs.exists("/API/Functions.lua")
  1492. local file1 = fs.exists("/API/Button.lua")
  1493.  
  1494. Monitor[0].setBackgroundColor(colors.black)
  1495. Monitor[0].setTextColor(colors.white)
  1496.  
  1497. sleep(1)
  1498.  
  1499. if not(file0) then
  1500.    
  1501.     Monitor[0].setCursorPos(1, (h-1))
  1502.     Monitor[0].clearLine()
  1503.     Monitor[0].setBackgroundColor(colors.white)
  1504.     Monitor[0].setTextColor(colors.black)
  1505.     Monitor[0].setCursorPos(math.floor((w - string.len("Downloading Function file...")) /2), (h-1))
  1506.  
  1507.     SaveFile("log", "Downloading Function file...", true)
  1508.    
  1509.     shell.run("pastebin get sujHjqXC /API/Functions.lua")
  1510.    
  1511.     Monitor[0].setBackgroundColor(colors.black)
  1512.     Monitor[0].setTextColor(colors.white)
  1513.    
  1514.     sleep(1)
  1515.    
  1516. end
  1517.  
  1518. if not(file1) then
  1519.    
  1520.     Monitor[0].setCursorPos(1, (h-1))
  1521.     Monitor[0].clearLine()
  1522.     Monitor[0].setBackgroundColor(colors.white)
  1523.     Monitor[0].setTextColor(colors.black)
  1524.     Monitor[0].setCursorPos(math.floor((w - string.len("Downloading Button file...")) /2), (h-1))
  1525.  
  1526.     SaveFile("log", "Downloading Button file...", true)
  1527.    
  1528.     shell.run("pastebin get mKpxpWmZ /API/Button.lua")
  1529.    
  1530.     Monitor[0].setBackgroundColor(colors.black)
  1531.     Monitor[0].setTextColor(colors.white)
  1532.    
  1533.     sleep(1)
  1534.    
  1535. end
  1536.  
  1537. Monitor[0].clear()
  1538.  
  1539. Logo.drawLogo(Monitor[0], "Head", math.floor(w/2)-6, math.floor(h/2)-4)
  1540.  
  1541. Monitor[0].setCursorPos(1, (h-1))
  1542. Monitor[0].clearLine()
  1543. Monitor[0].setBackgroundColor(colors.white)
  1544. Monitor[0].setTextColor(colors.black)
  1545. Monitor[0].setCursorPos(math.floor((w - string.len("Installing files...")) /2), (h-1))
  1546.  
  1547. SaveFile("log", "Installing files...", true)
  1548.  
  1549. System.loadAPI("/API/Functions.lua")
  1550. System.loadAPI("/API/Button.lua")
  1551.  
  1552. Button.setMonitor(false)
  1553. Button.setColors(colors.blue, colors.white, colors.white, colors.blue)
  1554.  
  1555. Functions.SetColors(Monitor[0], colors.black, colors.white)
  1556.  
  1557. sleep(1)
  1558.  
  1559. Monitor[0].clear()
  1560.  
  1561. Logo.drawLogo(Monitor[0], "Sub", 1, 1)
  1562.  
  1563. SaveFile("log", "Looking for Fuel", false)
  1564.  
  1565. Monitor[0].write("Looking for Fuel ")
  1566.  
  1567. T.select(1)
  1568.  
  1569. if T.getFuelLevel() < 50 then
  1570.    
  1571.     local succes = {}
  1572.    
  1573.     for i = 1, 13 do
  1574.         T.select(i)
  1575.         table.insert(succes, i, T.refuel())
  1576.     end
  1577.    
  1578.     T.select(1)
  1579.    
  1580.     local F = false
  1581.    
  1582.     for i = 1, #succes do
  1583.        
  1584.         if succes[i] then
  1585.            
  1586.             F = true
  1587.            
  1588.         end
  1589.        
  1590.     end
  1591.    
  1592.     if not(F) then
  1593.        
  1594.         local succes1, details = T.inspect()
  1595.        
  1596.         succes = {}
  1597.        
  1598.         if succes1 then
  1599.             if string.find(details.name, "log") then
  1600.                 T.dig()
  1601.                 table.insert(succes, T.refuel())
  1602.                 F = false
  1603.                 for i = 1, #succes do
  1604.                     if succes[i] then
  1605.                         F = true
  1606.                     end
  1607.                 end
  1608.                 if not(F) then
  1609.                     print("X")
  1610.                     SaveFile("log", "Cant refuel", true)
  1611.                     error()
  1612.                 end
  1613.             else
  1614.                 print("X")
  1615.                 SaveFile("log", "Cant refuel", true)
  1616.                 error()
  1617.             end
  1618.         else
  1619.             print("X")
  1620.             SaveFile("log", "Cant refuel", true)
  1621.             error()
  1622.         end
  1623.        
  1624.     end
  1625.    
  1626.     print("V")
  1627.    
  1628. else
  1629.    
  1630.     print("V")
  1631.    
  1632. end
  1633.  
  1634. SaveFile("log", "Loading Status", true)
  1635.  
  1636. file = fs.exists("/.Status.st")
  1637.  
  1638. if file then
  1639.    
  1640.     file = fs.open("/.Status.st", "r")
  1641.     Status = tonumber(file.readLine())
  1642.     file.close()
  1643.    
  1644. else
  1645.    
  1646.     file = fs.open("/.Status.st", "w")
  1647.     file.write(Status)
  1648.     file.close()
  1649.    
  1650. end
  1651.  
  1652. SaveFile("log", "Loaded Status: "..Status, true)
  1653.  
  1654. SaveFile("log", "Looking for Tools", false)
  1655. Monitor[0].write("Looking for Tools ")
  1656.  
  1657. if Status > 2 then
  1658.    
  1659.     for i = 1, 2 do
  1660.         T.forward()
  1661.     end
  1662.    
  1663.     T.select(10)
  1664.     T.equipLeft()
  1665.     T.select(11)
  1666.     Toolequip()
  1667.     T.select(1)
  1668.    
  1669.     local succes = T.suckDown()
  1670.    
  1671.     if succes then
  1672.        
  1673.         while T.suckDown() do end
  1674.        
  1675.         for i = 1, 16 do
  1676.            
  1677.             local details = T.getItemDetail(i)
  1678.            
  1679.             if details then
  1680.                
  1681.                 if string.find(details.name, Tools[1]) then
  1682.                    
  1683.                     T.select(i)
  1684.                     Toolequip()
  1685.                    
  1686.                 elseif details.name == Tools[2] then
  1687.                    
  1688.                     T.select(i)
  1689.                     equipLeft = T.equipLeft()
  1690.                    
  1691.                 end
  1692.                
  1693.             end
  1694.            
  1695.         end
  1696.        
  1697.         for i = 1, 16 do
  1698.             if T.getItemDetail(i) ~= nil and not(string.find(T.getItemDetail(i).name, "chest")) then
  1699.                 T.select(i)
  1700.                 T.dropDown()
  1701.             end
  1702.         end
  1703.        
  1704.         for i = 1, 14 do
  1705.             if T.getItemDetail(i) ~= nil and string.find(T.getItemDetail(i).name, "chest") then
  1706.                 T.select(i)
  1707.                 T.transferTo(chestSlot, 1)
  1708.             end
  1709.         end
  1710.        
  1711.         for i = 1, 14 do
  1712.             T.select(i)
  1713.             T.dropDown()
  1714.         end
  1715.        
  1716.     else
  1717.        
  1718.         for i = 1, 16 do
  1719.            
  1720.             local details = T.getItemDetail(i)
  1721.            
  1722.             if details then
  1723.                
  1724.                 for _, name in ipairs(Tools) do
  1725.                    
  1726.                     if details.name == name then
  1727.                        
  1728.                         if string.find(details.name, Tools[1]) then
  1729.                            
  1730.                             T.select(i)
  1731.                             Toolequip()
  1732.                            
  1733.                         elseif details.name == Tools[2] then
  1734.                            
  1735.                             T.select(i)
  1736.                             equipLeft = T.equipLeft()
  1737.                            
  1738.                         end
  1739.                        
  1740.                     end
  1741.                    
  1742.                 end
  1743.                
  1744.             end
  1745.            
  1746.         end
  1747.        
  1748.     end
  1749.    
  1750.     T.select(1)
  1751.    
  1752.     for i = 1, 2 do
  1753.         T.back()
  1754.     end
  1755.    
  1756.     if not(equipLeft) then
  1757.        
  1758.         print("X")
  1759.         SaveFile("log", "Tool not found: "..Tools[2], true)
  1760.         error()
  1761.        
  1762.     end
  1763.    
  1764.     print("V")
  1765.    
  1766. else
  1767.    
  1768.     T.select(10)
  1769.     T.equipLeft()
  1770.     T.select(11)
  1771.     Toolequip()
  1772.     T.select(1)
  1773.    
  1774.     for i = 1, 16 do
  1775.        
  1776.         local details = T.getItemDetail(i)
  1777.        
  1778.         if details then
  1779.            
  1780.             if string.find(details.name, Tools[1]) then
  1781.                
  1782.                 T.select(i)
  1783.                 Toolequip()
  1784.                
  1785.             elseif details.name == Tools[2] then
  1786.                
  1787.                 T.select(i)
  1788.                 equipLeft = T.equipLeft()
  1789.                
  1790.             end
  1791.            
  1792.         end
  1793.        
  1794.     end
  1795.    
  1796.     T.select(1)
  1797.    
  1798.     if not(equipLeft) then
  1799.        
  1800.         print("X")
  1801.         SaveFile("log", "Tool not found: "..Tools[2], true)
  1802.         error()
  1803.        
  1804.     end
  1805.    
  1806.     print("V")
  1807.    
  1808. end
  1809.  
  1810. SaveFile("log", "Looking for GPS", false)
  1811.  
  1812. Monitor[0].write("Looking for GPS ")
  1813.  
  1814. local X,Y,Z = gps.locate(3)
  1815.  
  1816. T:setX(X)
  1817. T:setY(Y)
  1818. T:setZ(Z)
  1819.  
  1820. if not(T:getX()) and not(T:getY()) and not(T:getZ()) then
  1821.    
  1822.     print("X")
  1823.    
  1824.     print("What are the cordinates of the turtle?")
  1825.     Monitor[0].write("X: ")
  1826.     T:setX(tonumber(read()))
  1827.     Monitor[0].write("Y: ")
  1828.     T:setY(tonumber(read()))
  1829.     Monitor[0].write("Z: ")
  1830.     T:setZ(tonumber(read()))
  1831.     Monitor[0].write("R: ")
  1832.     T:setR(tonumber(read()))
  1833.    
  1834.     SaveFile("log", "Looking for home cordinates", false)
  1835.    
  1836.     Monitor[0].write("Looking for home cordinates ")
  1837.  
  1838.     local file = fs.exists("/HomeCor.txt")
  1839.  
  1840.     if file then
  1841.        
  1842.         print("V")
  1843.        
  1844.         file = fs.open("/HomeCor.txt", "r")
  1845.         local HomeCor = UnPack(file.readAll())
  1846.         file.close()
  1847.         T:setHomeX(HomeCor.X)
  1848.         T:setHomeY(HomeCor.Y)
  1849.         T:setHomeZ(HomeCor.Z)
  1850.         T:setHomeR(HomeCor.R)
  1851.        
  1852.         SaveFile("log", "Loaded home cordinates", true)
  1853.        
  1854.     else
  1855.        
  1856.         print("X")
  1857.         print("Cor: X: "..X.." Y: "..Y.." Z: "..Z)
  1858.         print("Are these the home cordinates? Y/N")
  1859.        
  1860.         local Event, p1, p2 = System.pullEvent("key")
  1861.        
  1862.         if p1 == keys.y then
  1863.            
  1864.             T:setHomeX(T.getX())
  1865.             T:setHomeY(T.getY())
  1866.             T:setHomeZ(T.getZ())
  1867.             T:setHomeR(T.getR())
  1868.             local HomeCor = {X = T:getHomeX(), Y = T:getHomeY(), Z = T:getHomeZ(), R = T:getHomeR()}
  1869.            
  1870.             local file = fs.open("/HomeCor.txt", "w")
  1871.             file.write(Pack(HomeCor))
  1872.             file.close()
  1873.            
  1874.         else
  1875.            
  1876.             print("What are the home cordinates of the turtle?")
  1877.             Monitor[0].write("X: ")
  1878.             T:HomeX(tonumber(read()))
  1879.             Monitor[0].write("Y: ")
  1880.             T:HomeY(tonumber(read()))
  1881.             Monitor[0].write("Z: ")
  1882.             T:HomeZ(tonumber(read()))
  1883.             Monitor[0].write("R: ")
  1884.             T:HomeR(tonumber(read()))
  1885.            
  1886.             local HomeCor = {X = T:getHomeX(), Y = T:getHomeY(), Z = T:getHomeZ(), R = T:getHomeR()}
  1887.            
  1888.             local file = fs.open("/HomeCor.txt", "w")
  1889.             file.write(Pack(HomeCor))
  1890.             file.close()
  1891.            
  1892.         end
  1893.        
  1894.         SaveFile("log", "Saved home cordinates", true)
  1895.        
  1896.     end
  1897.    
  1898. else
  1899.    
  1900.     print("V")
  1901.    
  1902.     local SX, SY, SZ = T:getX(), T:getY(), T:getZ()
  1903.    
  1904.     T.turnLeft()
  1905.     T.forward()
  1906.    
  1907.     X, Y, Z = gps.locate(3)
  1908.    
  1909.     T:setX(X)
  1910.     T:setY(Y)
  1911.     T:setZ(Z)
  1912.    
  1913.     if T:getX() == SX and T:getZ() == SZ then
  1914.        
  1915.         print("Cant move or low fuel!")
  1916.         error()
  1917.        
  1918.     elseif T:getX() < SX then
  1919.        
  1920.         T:setR(4)
  1921.        
  1922.     elseif T:getX() > SX then
  1923.        
  1924.         T:setR(2)
  1925.        
  1926.     elseif T:getZ() < SZ then
  1927.        
  1928.         T:setR(1)
  1929.        
  1930.     elseif T:getZ() > SZ then
  1931.        
  1932.         T:setR(3)
  1933.        
  1934.     end
  1935.    
  1936.     T.back()
  1937.  
  1938.     X, Y, Z = gps.locate(3)
  1939.    
  1940.     T:setX(X)
  1941.     T:setY(Y)
  1942.     T:setZ(Z)
  1943.    
  1944.     T.turnRight()
  1945.    
  1946.     T:setR(T:getR() - 1)
  1947.  
  1948.     T:setR((T:getR() + 1) % 4)
  1949.  
  1950.     T:setR(T:getR() + 1)
  1951.    
  1952.     SaveFile("log", "Looking for home cordinates", false)
  1953.    
  1954.     Monitor[0].write("Looking for home cordinates ")
  1955.  
  1956.     local file = fs.exists("/HomeCor.txt")
  1957.  
  1958.     if file then
  1959.        
  1960.         print("V")
  1961.        
  1962.         file = fs.open("/HomeCor.txt", "r")
  1963.         local HomeCor = UnPack(file.readAll())
  1964.         file.close()
  1965.         T:setHomeX(HomeCor.X)
  1966.         T:setHomeY(HomeCor.Y)
  1967.         T:setHomeZ(HomeCor.Z)
  1968.         T:setHomeR(HomeCor.R)
  1969.        
  1970.         SaveFile("log", "Loaded home cordinates", true)
  1971.        
  1972.     else
  1973.        
  1974.         print("X")
  1975.         print("Cor: X: "..T:getX().." Y: "..T:getY().." Z: "..T:getZ().." R: "..T:getR())
  1976.         print("Are these the home cordinates? Y/N")
  1977.        
  1978.         local Event, p1, p2 = System.pullEvent("key")
  1979.        
  1980.         if p1 == keys.y then
  1981.            
  1982.             T:setHomeX(T:getX())
  1983.             T:setHomeY(T:getY())
  1984.             T:setHomeZ(T:getZ())
  1985.             T:setHomeR(T:getR())
  1986.             local HomeCor = {X = T:getHomeX(), Y = T:getHomeY(), Z = T:getHomeZ(), R = T:getHomeR()}
  1987.            
  1988.             local file = fs.open("/HomeCor.txt", "w")
  1989.             file.write(Pack(HomeCor))
  1990.             file.close()
  1991.            
  1992.         else
  1993.            
  1994.             print("What are the home cordinates of the turtle?")
  1995.             Monitor[0].write("X: ")
  1996.             T:setHomeX(tonumber(read()))
  1997.             Monitor[0].write("Y: ")
  1998.             T:setHomeY(tonumber(read()))
  1999.             Monitor[0].write("Z: ")
  2000.             T:setHomeZ(tonumber(read()))
  2001.             Monitor[0].write("R: ")
  2002.             T:setHomeR(tonumber(read()))
  2003.            
  2004.             local HomeCor = {X = T:getHomeX(), Y = T:getHomeY(), Z = T:getHomeZ(), R = T:getHomeR()}
  2005.            
  2006.             local file = fs.open("/HomeCor.txt", "w")
  2007.             file.write(Pack(HomeCor))
  2008.             file.close()
  2009.            
  2010.         end
  2011.        
  2012.         SaveFile("log", "Saved home cordinates", true)
  2013.        
  2014.     end
  2015.    
  2016. end
  2017.  
  2018.  
  2019. function SortStorage(N)
  2020.    
  2021.     SaveFile("log", "Sorting storage", true)
  2022.    
  2023.     T:GoTo(Chests[1])
  2024.     T.select(1)
  2025.    
  2026.     local a, b = 0, 0
  2027.    
  2028.     for i = 1, 13 do T.suckDown() end
  2029.    
  2030.     if Status == 5 or Status == 6 then
  2031.         a = 8
  2032.     elseif Status > 6 then
  2033.         a = 9
  2034.     end
  2035.    
  2036.     if Status < 6 then
  2037.         b = 14
  2038.     elseif Status >= 6 then
  2039.         b = 13
  2040.     end
  2041.    
  2042.     for g = 2, a do
  2043.        
  2044.         T:GoTo(Chests[g])
  2045.        
  2046.         local Data = {{"niks"}, {"log", "planks", "stick", "sign", "ladder", "torch"}, {"stone"}, {"sand", "dirt", "sugar_cane", "glas", "paper"}, {"redstone"}, {"iron_ore", "iron_ingot", "gold_ore", "gold_ingot"}, {"coal"}, {"diamond", "lapis", "emerald"}, {"sapling","bone","seed"}}
  2047.        
  2048.         for i = 1, 16 do
  2049.            
  2050.             local Deta = T.getItemDetail(i)
  2051.            
  2052.             if Deta then
  2053.                
  2054.                 for j = 1, #Data[g] do
  2055.                    
  2056.                     if g == 3 and not(string.find(Deta.name, "redstone")) and string.find(Deta.name, Data[g][j]) then
  2057.                        
  2058.                         T.select(i)
  2059.                         T.dropDown()
  2060.                        
  2061.                     elseif g ~= 3 and string.find(Deta.name, Data[g][j]) then
  2062.                        
  2063.                         T.select(i)
  2064.                         T.dropDown()
  2065.                        
  2066.                     end
  2067.                    
  2068.                 end
  2069.                
  2070.             end
  2071.            
  2072.         end
  2073.        
  2074.         GetChest()
  2075.         T.select(chestSlot)
  2076.         T.placeUp()
  2077.        
  2078.         T.select(1)
  2079.        
  2080.         local chest1 = Per.wrap("bottom")
  2081.         local chest2 = Per.wrap("top")
  2082.        
  2083.         local size1 = chest1.size()
  2084.         local size2 = chest2.size()
  2085.        
  2086.         for i = 1, size1 do
  2087.            
  2088.             chest1.pushItems("top", i, 64)
  2089.            
  2090.         end
  2091.        
  2092.         for i = 1, size2 do
  2093.        
  2094.             local Deta = chest2.getItemDetail(i)
  2095.            
  2096.             if Deta then
  2097.                
  2098.                 for j = 1, #Data[g] do
  2099.                    
  2100.                     if g == 3 and not(string.find(Deta.name, "redstone")) and string.find(Deta.name, Data[g][j]) then
  2101.                        
  2102.                         chest2.pushItems("bottom", i, 64)
  2103.                        
  2104.                     elseif g ~= 3 and string.find(Deta.name, Data[g][j]) then
  2105.                        
  2106.                         chest2.pushItems("bottom", i, 64)
  2107.                        
  2108.                     end
  2109.                    
  2110.                 end
  2111.                
  2112.             end
  2113.            
  2114.         end
  2115.        
  2116.         while T.suckUp() do end
  2117.        
  2118.         T.select(chestSlot)
  2119.         T.digUp()
  2120.        
  2121.         T.select(1)
  2122.        
  2123.     end
  2124.    
  2125.     T:GoTo(Chests[1])
  2126.    
  2127.     for i = 1, b do
  2128.        
  2129.         T.select(i)
  2130.         T.dropDown()
  2131.        
  2132.     end
  2133.    
  2134.     if N == nil or N == 0 or N == 1 then
  2135.        
  2136.         SortStorage(2)
  2137.        
  2138.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  2139.        
  2140.         T:TurnDirection(T:getHomeR())
  2141.        
  2142.     end
  2143.    
  2144.    
  2145. end
  2146.  
  2147.  
  2148. function checkForOre()
  2149.    
  2150.     local Data = "minecraft:coal_ore,minecraft:iron_ore,minecraft:redstone_ore,minecraft:diamond_ore,minecraft:gold_ore,minecraft:emerald_ore,minecraft:lapis_ore"
  2151.    
  2152.     for i = 1, 4 do
  2153.        
  2154.         local succes2, data2 = T.inspectDown()
  2155.        
  2156.         if succes2 then
  2157.            
  2158.             if data2.name == "minecraft:lava" and T:getLavafoundLava() == false and Status > 7 then
  2159.                
  2160.                 T:setLava(true)
  2161.                 local slot = T.getSelectedSlot()
  2162.                 T.select(bucketSlot)
  2163.                 T.placeDown()
  2164.                 T.select(slot)
  2165.                
  2166.             elseif string.find(Data, data2.name) then
  2167.                
  2168.                 T.digDown()
  2169.                 T:Down()
  2170.                 checkForOre()
  2171.                 T:Up()
  2172.                
  2173.             end
  2174.            
  2175.         end
  2176.        
  2177.         local succes1, data1 = T.inspectUp()
  2178.        
  2179.         if succes1 then
  2180.            
  2181.             if data1.name == "minecraft:lava" and T:getLavafoundLava() == false and Status > 7 then
  2182.                
  2183.                 T:setLava(true)
  2184.                 local slot = T.getSelectedSlot()
  2185.                 T.select(bucketSlot)
  2186.                 T.placeUp()
  2187.                 T.select(slot)
  2188.                
  2189.             elseif string.find(Data, data1.name) then
  2190.                
  2191.                 T.digUp()
  2192.                 T:Up()
  2193.                 checkForOre()
  2194.                 T:Down()
  2195.                
  2196.             end
  2197.            
  2198.         end
  2199.        
  2200.         local succes, data = T.inspect()
  2201.        
  2202.         if succes then
  2203.            
  2204.             if data.name == "minecraft:lava" and T:getLavafoundLava() == false and Status > 7 then
  2205.                
  2206.                 T:setLava(true)
  2207.                 local slot = T.getSelectedSlot()
  2208.                 T.select(bucketSlot)
  2209.                 T.place()
  2210.                 T.select(slot)
  2211.                
  2212.             elseif string.find(Data, data.name) then
  2213.                
  2214.                 T.dig()
  2215.                 T:Forward()
  2216.                 checkForOre()
  2217.                 T:Back()
  2218.                
  2219.             end
  2220.            
  2221.         end
  2222.        
  2223.         T:TurnLeft()
  2224.        
  2225.     end
  2226.    
  2227. end
  2228.  
  2229. function checkForLeaves()
  2230.    
  2231.     for i = 1, 4 do
  2232.        
  2233.         local succes, data = T.inspect()
  2234.        
  2235.         if succes then
  2236.            
  2237.             if string.find(data.name, "leaves") or string.find(data.name, "oak") then
  2238.                
  2239.                 T.dig()
  2240.                 T:Forward()
  2241.                 checkForLeaves()
  2242.                 T:Back()
  2243.                
  2244.             end
  2245.            
  2246.         end
  2247.        
  2248.         T:TurnLeft()
  2249.        
  2250.     end
  2251.    
  2252. end
  2253.  
  2254.  
  2255. function HarvestTrees(N)
  2256.    
  2257.     local succes, details = T.inspect()
  2258.    
  2259.     while not(succes) do
  2260.         Monitor[0].write("Plant Sapling!!!")
  2261.         sleep(25)
  2262.         Monitor[0].clearLine()
  2263.         sleep(5)
  2264.         succes, details = T.inspect()
  2265.     end
  2266.    
  2267.     while succes and not(string.find(details.name, "log")) do
  2268.         sleep(30)
  2269.         succes, details = T.inspect()
  2270.     end
  2271.    
  2272.     T.select(1)
  2273.     T.dig()
  2274.     T:Forward()
  2275.    
  2276.     local a = 0
  2277.    
  2278.     while T.detectUp() do
  2279.         T.digUp()
  2280.         T:Up()
  2281.         a = T:Add(a, 1)
  2282.         checkForLeaves()
  2283.     end
  2284.    
  2285.     if N == 1 then
  2286.         T.refuel(2)
  2287.     end
  2288.    
  2289.     for i = 1, a do
  2290.         T:Down()
  2291.     end
  2292.    
  2293.     T:Back()
  2294.    
  2295. end
  2296.  
  2297. function FirstTree()
  2298.    
  2299.     T.select(1)
  2300.    
  2301.     if T.getFuelLevel() <= 50 then
  2302.         if not(T.refuel()) then
  2303.             T.dig()
  2304.             T.refuel()
  2305.         end
  2306.     end
  2307.    
  2308.     T.select(1)
  2309.    
  2310.     SaveFile("log", "First tree", false)
  2311.     Monitor[0].write("First tree ")
  2312.    
  2313.     for i = 1, 10 do
  2314.        
  2315.         HarvestTrees(1)
  2316.        
  2317.         local number, Slots = T:LookInvItems("sapling", true)
  2318.        
  2319.         if number > 0 then
  2320.            
  2321.             T.select(Slots[1])
  2322.             T.place()
  2323.             T.select(1)
  2324.            
  2325.             local succes, details = T.inspect()
  2326.            
  2327.             while not(string.find(details.name, "log")) do
  2328.                
  2329.                 sleep(30)
  2330.                 succes, details = T.inspect()
  2331.                
  2332.             end
  2333.            
  2334.         end
  2335.        
  2336.     end
  2337.    
  2338.     for i = 1, 16 do
  2339.        
  2340.         local details = T.getItemDetail(i)
  2341.        
  2342.         if not(string.find(details.name, "log")) then
  2343.            
  2344.             T.select(i)
  2345.             T.refuel()
  2346.            
  2347.         end
  2348.        
  2349.     end
  2350.    
  2351.     T.select(1)
  2352.    
  2353.     print("V")
  2354.    
  2355.     Status = 2
  2356.    
  2357.     SaveFile("status")
  2358.    
  2359. end
  2360.  
  2361. function ChopTree()
  2362.    
  2363.     SaveFile("log", "Chop tree", true)
  2364.    
  2365.     T.select(1)
  2366.     T.dig()
  2367.     T:Forward()
  2368.    
  2369.     local a = 0
  2370.    
  2371.     while T.detectUp() do
  2372.         T.digUp()
  2373.         T:Up()
  2374.         a = T:Add(a, 1)
  2375.         checkForLeaves()
  2376.     end
  2377.    
  2378.     for i = 1, a do
  2379.         T:Down()
  2380.     end
  2381.    
  2382.     T:Back()
  2383.    
  2384. end
  2385.  
  2386. function MakeChest()
  2387.    
  2388.     T.select(16)
  2389.     Toolequip()
  2390.     local CT = false
  2391.    
  2392.     SaveFile("log", "Looking for crafting table", true)
  2393.    
  2394.     local i = 1
  2395.    
  2396.     while not(CT) do
  2397.        
  2398.         local count, slot = T:LookInvItems(Tools[4], false)
  2399.        
  2400.         if count > 0 then
  2401.            
  2402.             SaveFile("log", "Found crafting table", true)
  2403.             CT = true
  2404.             T.select(slot[1])
  2405.             Toolequip()
  2406.            
  2407.         end
  2408.        
  2409.         if not(CT)then
  2410.            
  2411.             if i == 1 then
  2412.                
  2413.                 SaveFile("log", "Waiting for crafting table", true)
  2414.                 i = 2
  2415.                
  2416.             end
  2417.            
  2418.             sleep(1,5)
  2419.            
  2420.         end
  2421.        
  2422.     end
  2423.    
  2424.     GetModem()
  2425.    
  2426.     SaveFile("log", "Crafting Chest", true)
  2427.    
  2428.     local count, slots = T:LookInvItems("log", true)
  2429.    
  2430.     if count >= 6 then
  2431.        
  2432.         for i = 1, 16 do
  2433.            
  2434.             for j = 1, #slots do
  2435.                
  2436.                 if i ~= slots[j] then
  2437.                    
  2438.                     T.select(i)
  2439.                     T.drop()
  2440.                    
  2441.                 end
  2442.                
  2443.             end
  2444.            
  2445.         end
  2446.        
  2447.         for i = 2, #slots do
  2448.             T.select(i)
  2449.             T.drop()
  2450.            
  2451.         end
  2452.        
  2453.         T.select(slots[1])
  2454.         T.transferTo(4, 64)
  2455.         T.select(4)
  2456.         T.transferTo(1, 6)
  2457.         T.drop()
  2458.         T.craft(4)
  2459.         T.transferTo(1, 3)
  2460.         T.transferTo(2, 3)
  2461.         T.transferTo(3, 3)
  2462.         T.transferTo(5, 3)
  2463.         T.transferTo(7, 3)
  2464.         T.transferTo(9, 3)
  2465.         T.transferTo(10, 3)
  2466.         T.transferTo(11, 3)
  2467.         T.select(4)
  2468.         T.drop()
  2469.         T.select(8)
  2470.         T.drop()
  2471.         T.select(12)
  2472.         T.drop()
  2473.         T.select(13)
  2474.         T.drop()
  2475.         T.select(14)
  2476.         T.drop()
  2477.         T.select(15)
  2478.         T.drop()
  2479.         T.select(16)
  2480.         T.drop()
  2481.         T.select(8)
  2482.         T.craft(2)
  2483.         T.transferTo(chestSlot, 1)
  2484.        
  2485.         SaveFile("log", "Making little storage", true)
  2486.        
  2487.         for i = 1, 2 do
  2488.             local Succec = T.suck()
  2489.            
  2490.             while Succec do
  2491.                 Succec = T.suck()
  2492.             end
  2493.            
  2494.             T.dig()
  2495.             T:Forward()
  2496.         end
  2497.        
  2498.         T.dig()
  2499.        
  2500.         local Succec = T.suck()
  2501.        
  2502.         while Succec do
  2503.             Succec = T.suck()
  2504.         end
  2505.        
  2506.         GetModem()
  2507.        
  2508.         T.select(8)
  2509.        
  2510.         T.digDown()
  2511.         T.placeDown()
  2512.        
  2513.         Chests[1].X, Chests[1].Y, Chests[1].Z = T:getX(), T:getY(), T:getZ()
  2514.        
  2515.         SaveFile("chests")
  2516.        
  2517.         T:TurnRight()
  2518.         T:Forward()
  2519.         T:TurnLeft()
  2520.         T.placeDown()
  2521.        
  2522.         T:TurnRight()
  2523.         T:Back()
  2524.         T:TurnLeft()
  2525.         T:Back()
  2526.         T:Back()
  2527.        
  2528.     else
  2529.        
  2530.         SaveFile("log", "No Logs Found", true)
  2531.         error()
  2532.        
  2533.     end
  2534.    
  2535.     T:emptyInv()
  2536.    
  2537.     Status = 3
  2538.    
  2539.     SaveFile("status")
  2540.    
  2541. end
  2542.  
  2543. function HarvestAllTrees()
  2544.    
  2545.     if T.getFuelLevel() < 500 and Status > 5 then
  2546.         T:Refuel()
  2547.     elseif T.getFuelLevel() < 500 and Status <= 5 then
  2548.        
  2549.         local succes, Succes = {}, false
  2550.        
  2551.         for i = 1, 13 do
  2552.             T.select(i)
  2553.             table.insert(succes, T.refuel())
  2554.         end
  2555.        
  2556.         T.select(1)
  2557.        
  2558.         for i = 1, succes do
  2559.             if succes[i] then
  2560.                 Succes = true
  2561.             end
  2562.         end
  2563.        
  2564.         while not(Succes) do
  2565.            
  2566.             local succes1, details = T.inspect()
  2567.            
  2568.             succes = {}
  2569.            
  2570.             if succes1 then
  2571.                 if string.find(details.name, "log") then
  2572.                     T.dig()
  2573.                     table.insert(succes, T.refuel())
  2574.                 else
  2575.                     print("X")
  2576.                     SaveFile("log", "Cant refuel", true)
  2577.                     error()
  2578.                 end
  2579.             else
  2580.                 print("X")
  2581.                 SaveFile("log", "Cant refuel", true)
  2582.                 error()
  2583.             end
  2584.            
  2585.             for i = 1, succes do
  2586.                 if succes[i] then
  2587.                     Succes = true
  2588.                 end
  2589.             end
  2590.         end
  2591.        
  2592.     end
  2593.    
  2594.     GetModem()
  2595.    
  2596.     SaveFile("log", "Looking for all trees in 32X32 erea", true)
  2597.    
  2598.     local a = 1
  2599.    
  2600.     while a < 33 do
  2601.        
  2602.         if T.getFuelLevel() < 500 then
  2603.             T:Refuel()
  2604.         end
  2605.        
  2606.         for i = 1, 2 do
  2607.            
  2608.             for I = 1, a do
  2609.                
  2610.                 local succes, tabel = T.inspect()
  2611.                 local succes1, tabel1 = T.inspectDown()
  2612.                
  2613.                 if not(succes1) then
  2614.                     T:Down()
  2615.                 elseif succes1 then
  2616.                     if string.find(tabel1.name, "log") then
  2617.                         T.digDown()
  2618.                         T:Down()
  2619.                     elseif string.find(tabel1.name, "water") then
  2620.                         if not(Water.found) then
  2621.                             Water.found = true
  2622.                             Water.x, Water.y, Water.z = T:getX(), T:getY(), T:getZ()
  2623.                             SaveFile("log", "Water found: "..tostring(Water.found).." at: "..Water.x.." "..Water.y.." "..Water.z, true)
  2624.                             SaveFile("locations")
  2625.                         end
  2626.                     elseif tabel1.name == "minecraft:sand" or tabel1.name == "minecraft:red_sand" then
  2627.                         if not(Sand.found) then
  2628.                             Sand.found = true
  2629.                             Sand.x, Sand.y, Sand.z = T:getX(), T:getY(), T:getZ()
  2630.                             SaveFile("log", "Sand found: "..tostring(Sand.found).." at: "..Sand.x.." "..Sand.y.." "..Sand.z, true)
  2631.                             SaveFile("locations")
  2632.                         end
  2633.                     end
  2634.                 end
  2635.                
  2636.                 if succes then
  2637.                    
  2638.                     if string.find(tabel.name, "log") then
  2639.                         ChopTree()
  2640.                     elseif string.find(tabel.name, "sugar_cane") then
  2641.                         while T.detect() do
  2642.                             T:Up()
  2643.                         end
  2644.                         T:Forward()
  2645.                        
  2646.                         local succes1, tabel1 = T.inspectDown()
  2647.                        
  2648.                         while string.find(tabel1.name, "sugar_cane") do
  2649.                             T.digDown()
  2650.                             T:Down()
  2651.                             succes1, tabel1 = T.inspectDown()
  2652.                         end
  2653.                         T:Back()
  2654.                     end
  2655.                    
  2656.                     while T.detect() do
  2657.                         T.digUp()
  2658.                         T:Up()
  2659.                         succes, tabel = T.inspect()
  2660.                         if succes then
  2661.                             if string.find(tabel.name, "log") then
  2662.                                 ChopTree()
  2663.                             end
  2664.                         end
  2665.                     end
  2666.                    
  2667.                 end
  2668.                
  2669.                 T:Forward()
  2670.                
  2671.             end
  2672.            
  2673.             T:TurnRight()
  2674.         end
  2675.        
  2676.         a = T:Add(a, 1)
  2677.        
  2678.     end
  2679.    
  2680.     T:GoHome()
  2681.    
  2682.     T:emptyInv()
  2683.    
  2684.     Status = 4
  2685.    
  2686.     SaveFile("status")
  2687.    
  2688. end
  2689.  
  2690. function GetCobbleStone()
  2691.    
  2692.     if not(Water.found) and not(Sand.found) then
  2693.        
  2694.         SaveFile("log", "Sand found: "..tostring(Sand.found).." Water found: "..tostring(Water.found), true)
  2695.         error()
  2696.        
  2697.     elseif not(Water.found) then
  2698.        
  2699.         SaveFile("log", "Water found: "..tostring(Water.found), true)
  2700.         error()
  2701.        
  2702.     elseif not(Sand.found) then
  2703.        
  2704.         SaveFile("log", "Sand found: "..tostring(Sand.found), true)
  2705.         error()
  2706.        
  2707.     end
  2708.    
  2709.     if T.getFuelLevel() < 500 and Status > 5 then
  2710.         T:Refuel()
  2711.     elseif T.getFuelLevel() < 500 and Status <= 5 then
  2712.        
  2713.         local succes, Succes = {}, false
  2714.        
  2715.         for i = 1, 13 do
  2716.             T.select(i)
  2717.             table.insert(succes, T.refuel())
  2718.         end
  2719.        
  2720.         T.select(1)
  2721.        
  2722.         for i = 1, succes do
  2723.             if succes[i] then
  2724.                 Succes = true
  2725.             end
  2726.         end
  2727.        
  2728.         while not(Succes) do
  2729.            
  2730.             local succes1, details = T.inspect()
  2731.            
  2732.             succes = {}
  2733.            
  2734.             if succes1 then
  2735.                 if string.find(details.name, "log") then
  2736.                     T.dig()
  2737.                     table.insert(succes, T.refuel())
  2738.                 else
  2739.                     print("X")
  2740.                     SaveFile("log", "Cant refuel", true)
  2741.                     error()
  2742.                 end
  2743.             else
  2744.                 print("X")
  2745.                 SaveFile("log", "Cant refuel", true)
  2746.                 error()
  2747.             end
  2748.            
  2749.             for i = 1, succes do
  2750.                 if succes[i] then
  2751.                     Succes = true
  2752.                 end
  2753.             end
  2754.         end
  2755.        
  2756.     end
  2757.    
  2758.     GetModem()
  2759.    
  2760.     SaveFile("log", "Looking for cobblestone", true)
  2761.    
  2762.     T.select(1)
  2763.    
  2764.     while T:getY() > 7 do
  2765.        
  2766.         T.digDown()
  2767.         T:Down()
  2768.         checkForOre()
  2769.         for i = 1,4 do
  2770.             T.dig()
  2771.             T:TurnLeft()
  2772.            
  2773.         end
  2774.        
  2775.     end
  2776.    
  2777.     for i = 1, 64 do
  2778.         checkForOre()
  2779.         T.dig()
  2780.         T.digUp()
  2781.         T.digDown()
  2782.         T:Forward()
  2783.         T:SortInvItems(1)
  2784.     end
  2785.    
  2786.     for i = 1, 64 do T:Back() end
  2787.    
  2788.     while T:getY() < (T:getHomeY() - 2) do
  2789.         T:Up()
  2790.     end
  2791.    
  2792.     local count, slots = T:LookInvItems("cobblestone", true)
  2793.    
  2794.     T.select(slots[1])
  2795.    
  2796.     for i = 1, 2 do
  2797.         for I = 1, 4 do
  2798.             T.place()
  2799.             T:TurnLeft()
  2800.         end
  2801.         T:Up()
  2802.         T.placeDown()
  2803.     end
  2804.    
  2805.     if T:getX() ~= T:getHomeX() or T:getY() ~= T:getHomeY() or T:getZ() ~= T:getHomeZ() or T:getR() ~= T:getHomeR() then
  2806.         -- gohome
  2807.         if T.getFuelLevel() <= 500 then
  2808.             T:Refuel()
  2809.         end
  2810.         T:GoHome()
  2811.     end
  2812.  
  2813.     T:emptyInv()
  2814.    
  2815.     Status = 5
  2816.    
  2817.     SaveFile("status")
  2818.    
  2819. end
  2820.  
  2821. function MakeStorage()
  2822.    
  2823.     if T.getFuelLevel() < 500 and Status > 5 then
  2824.         T:Refuel()
  2825.     elseif T.getFuelLevel() < 500 and Status <= 5 then
  2826.        
  2827.         local succes, Succes = {}, false
  2828.        
  2829.         for i = 1, 13 do
  2830.             T.select(i)
  2831.             table.insert(succes, T.refuel())
  2832.         end
  2833.        
  2834.         T.select(1)
  2835.        
  2836.         for i = 1, succes do
  2837.             if succes[i] then
  2838.                 Succes = true
  2839.             end
  2840.         end
  2841.        
  2842.         while not(Succes) do
  2843.            
  2844.             local succes1, details = T.inspect()
  2845.            
  2846.             succes = {}
  2847.            
  2848.             if succes1 then
  2849.                 if string.find(details.name, "log") then
  2850.                     T.dig()
  2851.                     table.insert(succes, T.refuel())
  2852.                 else
  2853.                     print("X")
  2854.                     SaveFile("log", "Cant refuel", true)
  2855.                     error()
  2856.                 end
  2857.             else
  2858.                 print("X")
  2859.                 SaveFile("log", "Cant refuel", true)
  2860.                 error()
  2861.             end
  2862.            
  2863.             for i = 1, succes do
  2864.                 if succes[i] then
  2865.                     Succes = true
  2866.                 end
  2867.             end
  2868.         end
  2869.        
  2870.     end
  2871.  
  2872.     SaveFile("log", "Making chests", true)
  2873.    
  2874.     for i = 1, 2 do
  2875.         T:Forward()
  2876.     end
  2877.    
  2878.     GetChest()
  2879.     T.select(chestSlot)
  2880.     T.placeUp()
  2881.    
  2882.     local chest1 = Per.wrap("bottom")
  2883.    
  2884.     local size1 = chest1.size()
  2885.    
  2886.     T.select(4)
  2887.    
  2888.     for i = 1, size1 do
  2889.        
  2890.         local Details = chest1.getItemDetail(i)
  2891.        
  2892.         if Details then
  2893.            
  2894.             if string.find(Details.name, "log") or string.find(Details.name, "planks") then
  2895.                
  2896.                 chest1.pushItems("top", i, 64)
  2897.                
  2898.             end
  2899.            
  2900.         end
  2901.        
  2902.     end
  2903.    
  2904.     while T.suckUp() do end
  2905.    
  2906.     local count, slots = T:LookInvItems("planks", true)
  2907.     local Details = T.getItemDetail(slots[1])
  2908.    
  2909.     if Details.count >= 56 then
  2910.        
  2911.         SaveFile("log", "Crafting chest", true)
  2912.         T:Craft("chest", 7, "planks")
  2913.         T.transferTo(chestSlot)
  2914.        
  2915.     else
  2916.        
  2917.         count, slots  = T:LookInvItems("log", true)
  2918.         local Details = T.getItemDetail(slots[1])
  2919.        
  2920.         if Details.count >= 14 then
  2921.            
  2922.             SaveFile("log", "Crafting planks", true)
  2923.             T:Craft("planks", 56, "log")
  2924.            
  2925.             count, slots  = T:LookInvItems("planks", true)
  2926.            
  2927.             if count >= 56 then
  2928.                
  2929.                 SaveFile("log", "Crafting chest", true)
  2930.                 T:Craft("chest", 7, "planks")
  2931.                 T.transferTo(chestSlot)
  2932.                
  2933.             else
  2934.                
  2935.                 T.select(chestSlot)
  2936.                 T.digUp()
  2937.                 for i = 1, 2 do
  2938.                     T:Back()
  2939.                 end
  2940.                 SaveFile("log", "Not enuf planks", true)
  2941.                 error()
  2942.                
  2943.             end
  2944.            
  2945.         else
  2946.            
  2947.             T.select(chestSlot)
  2948.             T.digUp()
  2949.             for i = 1, 2 do
  2950.                 T:Back()
  2951.             end
  2952.             SaveFile("log", "Not enuf logs", true)
  2953.             error()
  2954.            
  2955.         end
  2956.        
  2957.     end
  2958.    
  2959.     for i = 1, size1 do
  2960.        
  2961.         local Details = chest1.getItemDetail(i)
  2962.        
  2963.         if Details then
  2964.            
  2965.             if string.find(Details.name, "cobblestone") then
  2966.                
  2967.                 chest1.pushItems("top", i, 64)
  2968.                
  2969.             end
  2970.            
  2971.         end
  2972.        
  2973.     end
  2974.    
  2975.     T.select(1)
  2976.    
  2977.     while T.suckUp() do end
  2978.    
  2979.     T.select(chestSlot)
  2980.     T.digUp()
  2981.    
  2982.     for i = 1, 2 do
  2983.         T:Back()
  2984.     end
  2985.    
  2986.     SaveFile("log", "Making storage", true)
  2987.    
  2988.     local count, slots = T:LookInvItems("cobblestone", true)
  2989.    
  2990.     T.select(slots[1])
  2991.    
  2992.     T:TurnLeft()
  2993.     T:TurnLeft()
  2994.     T.checkUp()
  2995.     T.dig()
  2996.     T:Forward()
  2997.     T.checkUp()
  2998.     T.digDown()
  2999.     T.placeDown()
  3000.    
  3001.     T:TurnLeft()
  3002.     T.dig()
  3003.     T:Forward()
  3004.     T.checkUp()
  3005.     T.digDown()
  3006.     T.placeDown()
  3007.    
  3008.     T:TurnLeft()
  3009.     T:TurnLeft()
  3010.     T:Forward()
  3011.     T.checkUp()
  3012.     T.dig()
  3013.     T:Forward()
  3014.     T.checkUp()
  3015.     T.digDown()
  3016.     T.placeDown()
  3017.    
  3018.     T:Back()
  3019.     T.checkUp()
  3020.     T:TurnRight()
  3021.     T:Forward()
  3022.     T.checkUp()
  3023.     T.digDown()
  3024.     T.placeDown()
  3025.    
  3026.     T:TurnLeft()
  3027.     T.dig()
  3028.     T:Forward()
  3029.     T.checkUp()
  3030.     T.digDown()
  3031.     T.placeDown()
  3032.    
  3033.     T:TurnLeft()
  3034.     T:TurnLeft()
  3035.     T:Forward()
  3036.     T.checkUp()
  3037.     T.dig()
  3038.     T:Forward()
  3039.     T.checkUp()
  3040.     T.digDown()
  3041.     T.placeDown()
  3042.    
  3043.     T:Back()
  3044.     T.checkUp()
  3045.     T:TurnLeft()
  3046.     T:Forward()
  3047.     T.checkUp()
  3048.     T.digDown()
  3049.     T.placeDown()
  3050.    
  3051.     T:TurnLeft()
  3052.     T.dig()
  3053.     T:Forward()
  3054.     T.checkUp()
  3055.     T.digDown()
  3056.     T.placeDown()
  3057.    
  3058.     T:TurnLeft()
  3059.     T:TurnLeft()
  3060.     T:Forward()
  3061.     T.checkUp()
  3062.     T.dig()
  3063.     T:Forward()
  3064.     T.checkUp()
  3065.     T.digDown()
  3066.     T.placeDown()
  3067.    
  3068.     T:Back()
  3069.     T.checkUp()
  3070.     T:TurnLeft()
  3071.     T:Forward()
  3072.     T.checkUp()
  3073.    
  3074.     local a = 2
  3075.    
  3076.     for i = 1, 15 do
  3077.        
  3078.         if (i%2) == 1 and i < 16 then
  3079.            
  3080.             T.select(1)
  3081.             T.dig()
  3082.             T:Forward()
  3083.             T.checkUp()
  3084.             T.digDown()
  3085.             T.placeDown()
  3086.            
  3087.         else
  3088.            
  3089.             T.select(1)
  3090.             T.dig()
  3091.             T:Forward()
  3092.             T.checkUp()
  3093.             T.digDown()
  3094.             GetChest()
  3095.             T.select(chestSlot)
  3096.             T.placeDown()
  3097.             Chests[a].X, Chests[a].Y, Chests[a].Z = T:getX(), T:getY(), T:getZ()
  3098.             a = T:Add(a, 1)
  3099.             T.select(1)
  3100.            
  3101.         end
  3102.        
  3103.     end
  3104.    
  3105.     SaveFile("chests")
  3106.    
  3107.     for i = 1, 2 do
  3108.         T.dig()
  3109.         T:Forward()
  3110.     end
  3111.    
  3112.     Mine.x, Mine.y, Mine.z = T:getX(), T:getY(), T:getZ()
  3113.     Mine.found = true
  3114.    
  3115.     SaveFile("locations")
  3116.    
  3117.     for i = 1, 2 do
  3118.         T:Back()
  3119.     end
  3120.    
  3121.     T:TurnLeft()
  3122.     T.dig()
  3123.     T:Forward()
  3124.     T.checkUp()
  3125.     T.digDown()
  3126.     T.placeDown()
  3127.     T:TurnLeft()
  3128.    
  3129.     for i = 1, 16 do
  3130.        
  3131.         T.dig()
  3132.         T:Forward()
  3133.         T.checkUp()
  3134.         T.digDown()
  3135.         T.placeDown()
  3136.        
  3137.     end
  3138.    
  3139.     T:TurnLeft()
  3140.     T.dig()
  3141.     T:Forward()
  3142.     T.checkUp()
  3143.     T.dig()
  3144.     T:Forward()
  3145.     T.checkUp()
  3146.     T:TurnLeft()
  3147.    
  3148.     T.dig()
  3149.     T:Forward()
  3150.     T.checkUp()
  3151.     T.digDown()
  3152.     T.placeDown()
  3153.    
  3154.     T.dig()
  3155.     T:Forward()
  3156.     T.checkUp()
  3157.    
  3158.     for i = 1, 14 do
  3159.        
  3160.         T.dig()
  3161.         T:Forward()
  3162.         T.checkUp()
  3163.         T.digDown()
  3164.         T.placeDown()
  3165.        
  3166.     end
  3167.    
  3168.     T:GoHome()
  3169.    
  3170.     T:emptyInv()
  3171.    
  3172.     for i = 1, 2 do SortStorage() end
  3173.    
  3174.     Status = 6
  3175.    
  3176.     SaveFile("status")
  3177.    
  3178. end
  3179.  
  3180. function Makefurnace()
  3181.    
  3182.     SaveFile("log", "Crafting furnace", true)
  3183.    
  3184.     local number = T:findChest("stone")
  3185.    
  3186.     if number then
  3187.        
  3188.         T:GoTo(Chests[number])
  3189.         GetChest()
  3190.         T.select(chestSlot)
  3191.         T.placeUp()
  3192.        
  3193.         local chest1 = Per.wrap("bottom")
  3194.        
  3195.         local size1 = chest1.size()
  3196.        
  3197.         T.select(4)
  3198.        
  3199.         for i = 1, size1 do
  3200.            
  3201.             local Details = chest1.getItemDetail(i)
  3202.            
  3203.             if Details then
  3204.                
  3205.                 if string.find(Details.name, "cobblestone") then
  3206.                    
  3207.                     chest1.pushItems("top", i, 8)
  3208.                     break
  3209.                    
  3210.                 end
  3211.                
  3212.             end
  3213.            
  3214.         end
  3215.        
  3216.         while T.suckUp() do end
  3217.        
  3218.         local count, slots = T:LookInvItems("cobblestone", true)
  3219.        
  3220.         if count >= 8 then
  3221.            
  3222.             T:Craft("furnace", 1, "cobblestone")
  3223.            
  3224.         else
  3225.            
  3226.             SaveFile("log", "Not enuf cobblestone for furnace", true)
  3227.             error()
  3228.            
  3229.         end
  3230.        
  3231.         T.select(modemSlot)
  3232.        
  3233.         for i = 1, size1 do
  3234.            
  3235.             local Details = chest1.getItemDetail(i)
  3236.            
  3237.             if Details then
  3238.                
  3239.                 if string.find(Details.name, "modem") then
  3240.                    
  3241.                     chest1.pushItems("top", i, 1)
  3242.                     break
  3243.                    
  3244.                 end
  3245.                
  3246.             end
  3247.            
  3248.         end
  3249.        
  3250.         while T.suckUp() do end
  3251.        
  3252.         T.select(chestSlot)
  3253.         T.digUp()
  3254.        
  3255.         count, slots = T:LookInvItems("furnace", true)
  3256.        
  3257.         T.select(slots[1])
  3258.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  3259.         T:TurnDirection(T:getHomeR())
  3260.        
  3261.         SaveFile("log", "Placeing furnace", true)
  3262.        
  3263.         T:GoTo(Chests[1])
  3264.         T.placeUp()
  3265.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  3266.         T:TurnDirection(T:getHomeR())
  3267.        
  3268.     else
  3269.        
  3270.         SaveFile("log", "Cant find stone chest", true)
  3271.         error()
  3272.        
  3273.     end
  3274.    
  3275. end
  3276.  
  3277. function MakeBucket()
  3278.    
  3279.     SaveFile("log", "Crafting Bucket", true)
  3280.    
  3281.     local number = T:findChest("iron")
  3282.    
  3283.     if number then
  3284.        
  3285.         T:GoTo(Chests[number])
  3286.         GetChest()
  3287.         T.select(chestSlot)
  3288.         T.placeUp()
  3289.        
  3290.         local chest1 = Per.wrap("bottom")
  3291.        
  3292.         local size1 = chest1.size()
  3293.        
  3294.         T.select(4)
  3295.        
  3296.         for i = 1, size1 do
  3297.            
  3298.             local Details = chest1.getItemDetail(i)
  3299.            
  3300.             if Details then
  3301.                
  3302.                 if string.find(Details.name, "iron") then
  3303.                    
  3304.                     chest1.pushItems("top", i, 3)
  3305.                    
  3306.                 end
  3307.                
  3308.             end
  3309.            
  3310.         end
  3311.        
  3312.         while T.suckUp() do end
  3313.        
  3314.         local count, slots = T:LookInvItems("ingot", true)
  3315.        
  3316.         if count >= 3 then
  3317.            
  3318.             T:Craft("bucket", 1, "ingot")
  3319.            
  3320.             T.select(modemSlot)
  3321.            
  3322.             for i = 1, size1 do
  3323.                
  3324.                 local Details = chest1.getItemDetail(i)
  3325.                
  3326.                 if Details then
  3327.                    
  3328.                     if string.find(Details.name, "modem") then
  3329.                        
  3330.                         chest1.pushItems("top", i, 1)
  3331.                         break
  3332.                        
  3333.                     end
  3334.                    
  3335.                 end
  3336.                
  3337.             end
  3338.            
  3339.             while T.suckUp() do end
  3340.            
  3341.             T.select(chestSlot)
  3342.             T.digUp()
  3343.            
  3344.         else
  3345.            
  3346.             local count, slots = T:LookInvItems("ore", true)
  3347.            
  3348.             if count >= 3 then
  3349.                
  3350.                 for i = 1, 16 do
  3351.                    
  3352.                     local found = false
  3353.                    
  3354.                     for j = 1, #slots do
  3355.                        
  3356.                         if i == slots[j] then
  3357.                            
  3358.                             found = true
  3359.                            
  3360.                         end
  3361.                        
  3362.                     end
  3363.                    
  3364.                     if not(found) then
  3365.                        
  3366.                         clsTurtle.select(i)
  3367.                         clsTurtle.dropDown()
  3368.                        
  3369.                     end
  3370.                    
  3371.                 end
  3372.                
  3373.                 if #slots >= 2 then
  3374.                    
  3375.                     for i = 2, #slots do
  3376.                        
  3377.                         clsTurtle.select(slots[i])
  3378.                         clsTurtle.dropDown()
  3379.                        
  3380.                     end
  3381.                    
  3382.                 end
  3383.                
  3384.                 T.select(modemSlot)
  3385.        
  3386.                 for i = 1, size1 do
  3387.                    
  3388.                     local Details = chest1.getItemDetail(i)
  3389.                    
  3390.                     if Details then
  3391.                        
  3392.                         if string.find(Details.name, "modem") then
  3393.                            
  3394.                             chest1.pushItems("top", i, 1)
  3395.                             break
  3396.                            
  3397.                         end
  3398.                        
  3399.                     end
  3400.                    
  3401.                 end
  3402.                
  3403.                 while T.suckUp() do end
  3404.                
  3405.                 T.select(chestSlot)
  3406.                 T.digUp()
  3407.                
  3408.                 local number = T:findChest("wood")
  3409.                
  3410.                 if number then
  3411.                    
  3412.                     T:GoTo(Chests[number])
  3413.                     GetChest()
  3414.                     T.select(chestSlot)
  3415.                     T.placeUp()
  3416.                    
  3417.                     local chest1 = Per.wrap("bottom")
  3418.                    
  3419.                     local size1 = chest1.size()
  3420.                    
  3421.                     T.select(4)
  3422.                    
  3423.                     for i = 1, size1 do
  3424.                        
  3425.                         local Details = chest1.getItemDetail(i)
  3426.                        
  3427.                         if Details then
  3428.                            
  3429.                             if string.find(Details.name, "log") then
  3430.                                
  3431.                                 chest1.pushItems("top", i, 4)
  3432.                                 break
  3433.                                
  3434.                             end
  3435.                            
  3436.                         end
  3437.                        
  3438.                     end
  3439.                    
  3440.                     while T.suckUp() do end
  3441.                    
  3442.                     for i = 1, 16 do
  3443.                        
  3444.                         local Details = T.getItemDetail(i)
  3445.                        
  3446.                         if Details then
  3447.                            
  3448.                             if not(string.find(Details.name, "log")) and not(string.find(Details.name, "iron")) then
  3449.                                
  3450.                                 T.select(i)
  3451.                                 T.dropDown()
  3452.                                
  3453.                             end
  3454.                            
  3455.                         end
  3456.                        
  3457.                     end
  3458.                    
  3459.                     T.select(chestSlot)
  3460.                     T.digUp()
  3461.                    
  3462.                     T:GoTo(Chests[1])
  3463.                     T:TurnDirection(T.HomeR)
  3464.                    
  3465.                     local count1, slots1 = T:LookInvItems("ore", true)
  3466.                     local count2, slots2 = T:LookInvItems("log", true)
  3467.                    
  3468.                     T.select(slots1[1])
  3469.                     T:Back()
  3470.                    
  3471.                     for i = 1, 2 do
  3472.                        
  3473.                         T:Up()
  3474.                        
  3475.                     end
  3476.                    
  3477.                     T:Forward()
  3478.                     T.dropDown(3)
  3479.                     T.select(slots2[1])
  3480.                     T:Back()
  3481.                     T:Down()
  3482.                     T.suck()
  3483.                     T.drop(4)
  3484.                     T:Down()
  3485.                     T:GoTo(Chests[1])
  3486.                    
  3487.                     sleep(1)
  3488.                    
  3489.                     for i = 1, 16 do
  3490.                        
  3491.                         T.select(i)
  3492.                         T.dropDown()
  3493.                        
  3494.                     end
  3495.                    
  3496.                     sleep(29)
  3497.                    
  3498.                     T.select(4)
  3499.                     T.suckUp()
  3500.                    
  3501.                     T:Craft("bucket", 1, "ingot")
  3502.                    
  3503.                 else
  3504.                    
  3505.                     SaveFile("log", "Cant find wood chest", true)
  3506.                     error()
  3507.                    
  3508.                 end
  3509.                
  3510.             else
  3511.                
  3512.                 T.select(chestSlot)
  3513.                 T.digUp()
  3514.                 SaveFile("log", "Not enuf iron for bucket", true)
  3515.                 error()
  3516.                
  3517.             end
  3518.            
  3519.         end
  3520.        
  3521.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  3522.         T:TurnDirection(T:getHomeR())
  3523.         SortStorage()
  3524.         T:GoTo(Chests[1])
  3525.        
  3526.         T.select(1)
  3527.        
  3528.         while T.suckDown() do end
  3529.        
  3530.         local Details = T.getItemDetail(bucketSlot)
  3531.        
  3532.         if Details and not(string.find(Details.name, "bucket")) then
  3533.            
  3534.             T.select(bucketSlot)
  3535.             T.dropDown()
  3536.            
  3537.         end
  3538.        
  3539.         Details = T.getItemDetail(chestSlot)
  3540.        
  3541.         if Details and not(string.find(Details.name, "chest")) then
  3542.            
  3543.             T.select(chestSlot)
  3544.             T.dropDown()
  3545.            
  3546.         end
  3547.        
  3548.         for i = 1, 13 do
  3549.            
  3550.             Details = T.getItemDetail(i)
  3551.            
  3552.             T.select(i)
  3553.            
  3554.             if Details and string.find(Details.name, "chest") then
  3555.                
  3556.                 T.transferTo(chestSlot, 1)
  3557.                 T.dropDown()
  3558.                
  3559.             elseif Details and string.find(Details.name, "bucket") then
  3560.                
  3561.                 T.transferTo(bucketSlot, 1)
  3562.                 T.dropDown()
  3563.                
  3564.             else
  3565.                
  3566.                 T.dropDown()
  3567.                
  3568.             end
  3569.            
  3570.         end
  3571.        
  3572.         Details = T.getItemDetail(bucketSlot)
  3573.        
  3574.         if Details and not(string.find(Details.name, "bucket")) then
  3575.            
  3576.             GetChest()
  3577.             T.select(chestSlot)
  3578.             T.place()
  3579.            
  3580.             local chest1 = Per.wrap("bottom")
  3581.            
  3582.             local size1 = chest1.size()
  3583.            
  3584.             T.select(bucketSlot)
  3585.            
  3586.             for i = 1, size1 do
  3587.                
  3588.                 local Details = chest1.getItemDetail(i)
  3589.                
  3590.                 if Details and string.find(Details.name, "bucket") then
  3591.                    
  3592.                     chest1.pushItems("front", i, 1)
  3593.                     break
  3594.                
  3595.                 end
  3596.                
  3597.             end
  3598.            
  3599.             T.suck()
  3600.             T.select(chestSlot)
  3601.             T.dig()
  3602.            
  3603.         end
  3604.        
  3605.         T.select(1)
  3606.        
  3607.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  3608.         T:TurnDirection(T:getHomeR())
  3609.        
  3610.     else
  3611.        
  3612.         SaveFile("log", "Cant find iron chest", true)
  3613.         error()
  3614.        
  3615.     end
  3616.    
  3617. end
  3618.  
  3619. function MakeSaplingChest()
  3620.    
  3621.     SaveFile("log", "Crafting Chest", true)
  3622.    
  3623.     local number = T:findChest("wood")
  3624.    
  3625.     if number then
  3626.        
  3627.         T:GoTo(Chests[number])
  3628.         GetChest()
  3629.         T.select(chestSlot)
  3630.         T.placeUp()
  3631.        
  3632.         local chest1 = Per.wrap("bottom")
  3633.        
  3634.         local size1 = chest1.size()
  3635.        
  3636.         T.select(4)
  3637.        
  3638.         for i = 1, size1 do
  3639.            
  3640.             local Details = chest1.getItemDetail(i)
  3641.            
  3642.             if Details then
  3643.                
  3644.                 if string.find(Details.name, "log") then
  3645.                    
  3646.                     chest1.pushItems("top", i, 2)
  3647.                     break
  3648.                    
  3649.                 end
  3650.                
  3651.             end
  3652.            
  3653.         end
  3654.        
  3655.         while T.suckUp() do end
  3656.        
  3657.         T.select(bucketSlot)
  3658.         T.dropUp()
  3659.         T.select(modemSlot)
  3660.         T.dropUp()
  3661.         T:Craft("planks", 8, "log")
  3662.         T:Craft("chest", 1, "planks")
  3663.         local S = T.getSelectedSlot()
  3664.         T.select(bucketSlot)
  3665.         T.suckUp()
  3666.         T.select(modemSlot)
  3667.         T.suckUp()
  3668.         T.select(S)
  3669.         T.digUp()
  3670.         T.transferTo(chestSlot, 1)
  3671.        
  3672.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  3673.         T:TurnDirection(T:getHomeR())
  3674.        
  3675.         SaveFile("log", "Placeing Chest", true)
  3676.        
  3677.         T:TurnLeft()
  3678.         T:Forward()
  3679.         T.select(1)
  3680.        
  3681.         for i = 1, 2 do
  3682.            
  3683.             T.digDown()
  3684.             T:Down()
  3685.            
  3686.         end
  3687.        
  3688.         T.placeDown()
  3689.         T:Up()
  3690.        
  3691.         local count, slots = T:LookInvItems("chest", true)
  3692.        
  3693.         T.select(slots[1])
  3694.         T.placeDown()
  3695.         Chests[9].X, Chests[9].Y, Chests[9].Z = T:getX(), T:getY(), T:getZ()
  3696.         SaveFile("chests")
  3697.        
  3698.         T:Up()
  3699.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  3700.         T:TurnDirection(T:getHomeR())
  3701.         T.select(1)
  3702.        
  3703.         T:emptyInv()
  3704.        
  3705.         Status = 7
  3706.        
  3707.         SaveFile("status")
  3708.        
  3709.     else
  3710.        
  3711.         SaveFile("log", "Cant find wood chest", true)
  3712.         error()
  3713.        
  3714.     end
  3715.    
  3716. end
  3717.  
  3718. function MakeHopper()
  3719.    
  3720.     SaveFile("log", "Crafting Chest", true)
  3721.    
  3722.     local number = T:findChest("wood")
  3723.    
  3724.     if number then
  3725.        
  3726.         T:GoTo(Chests[number])
  3727.         GetChest()
  3728.         T.select(chestSlot)
  3729.         T.placeUp()
  3730.        
  3731.         local chest1 = Per.wrap("bottom")
  3732.        
  3733.         local size1 = chest1.size()
  3734.        
  3735.         T.select(4)
  3736.        
  3737.         for i = 1, size1 do
  3738.            
  3739.             local Details = chest1.getItemDetail(i)
  3740.            
  3741.             if Details then
  3742.                
  3743.                 if string.find(Details.name, "log") then
  3744.                    
  3745.                     chest1.pushItems("top", i, 2)
  3746.                     break
  3747.                    
  3748.                 end
  3749.                
  3750.             end
  3751.            
  3752.         end
  3753.        
  3754.         while T.suckUp() do end
  3755.        
  3756.         T:Craft("planks", 8, "log")
  3757.         T:Craft("chest", 1, "planks")
  3758.        
  3759.         T.select(2)
  3760.        
  3761.         for i = 1, size1 do
  3762.            
  3763.             local Details = chest1.getItemDetail(i)
  3764.            
  3765.             if Details then
  3766.                
  3767.                 if string.find(Details.name, "log") then
  3768.                    
  3769.                     chest1.pushItems("top", i, 4)
  3770.                     break
  3771.                    
  3772.                 end
  3773.                
  3774.             end
  3775.            
  3776.         end
  3777.        
  3778.         while T.suckUp() do end
  3779.        
  3780.         T.select(modemSlot)
  3781.        
  3782.         for i = 1, size1 do
  3783.            
  3784.             local Details = chest1.getItemDetail(i)
  3785.            
  3786.             if Details then
  3787.                
  3788.                 if string.find(Details.name, "modem") then
  3789.                    
  3790.                     chest1.pushItems("top", i, 1)
  3791.                     break
  3792.                    
  3793.                 end
  3794.                
  3795.             end
  3796.            
  3797.         end
  3798.        
  3799.         while T.suckUp() do end
  3800.        
  3801.         T.select(4)
  3802.         T.digUp()
  3803.         T.transferTo(chestSlot, 1)
  3804.         T.select(1)
  3805.        
  3806.         SaveFile("log", "Crafting Hopper", true)
  3807.        
  3808.         local number = T:findChest("iron")
  3809.        
  3810.         if number then
  3811.            
  3812.             T:GoTo(Chests[number])
  3813.             GetChest()
  3814.             T.select(chestSlot)
  3815.             T.placeUp()
  3816.            
  3817.             local chest1 = Per.wrap("bottom")
  3818.            
  3819.             local size1 = chest1.size()
  3820.            
  3821.             T.select(4)
  3822.            
  3823.             for i = 1, size1 do
  3824.                
  3825.                 local Details = chest1.getItemDetail(i)
  3826.                
  3827.                 if Details then
  3828.                    
  3829.                     if string.find(Details.name, "ore") then
  3830.                        
  3831.                         chest1.pushItems("top", i, 5)
  3832.                         break
  3833.                        
  3834.                     end
  3835.                    
  3836.                 end
  3837.                
  3838.             end
  3839.            
  3840.             while T.suckUp() do end
  3841.            
  3842.             T.select(modemSlot)
  3843.            
  3844.             for i = 1, size1 do
  3845.                
  3846.                 local Details = chest1.getItemDetail(i)
  3847.                
  3848.                 if Details then
  3849.                    
  3850.                     if string.find(Details.name, "modem") then
  3851.                        
  3852.                         chest1.pushItems("top", i, 1)
  3853.                         break
  3854.                        
  3855.                     end
  3856.                    
  3857.                 end
  3858.                
  3859.             end
  3860.            
  3861.             while T.suckUp() do end
  3862.            
  3863.             T.select(chestSlot)
  3864.             T.digUp()
  3865.            
  3866.             T:GoTo(Chests[1])
  3867.             T:TurnDirection(T:getHomeR())
  3868.            
  3869.             T:Back()
  3870.            
  3871.             for i = 1, 2 do
  3872.                
  3873.                 T:Up()
  3874.                
  3875.             end
  3876.            
  3877.             T:Forward()
  3878.            
  3879.             local count, slots = T:LookInvItems("ore", true)
  3880.            
  3881.             T.select(slots[1])
  3882.             T.dropDown()
  3883.            
  3884.             T:Back()
  3885.             T:Down()
  3886.            
  3887.             local count, slots = T:LookInvItems("log", true)
  3888.            
  3889.             T.select(slots[1])
  3890.             T.suck()
  3891.             T.drop(4)
  3892.             T:Down()
  3893.             T:Forward()
  3894.             T.dropDown()
  3895.            
  3896.             GetChest()
  3897.             T.select(chestSlot)
  3898.             T.place()
  3899.            
  3900.             T.select(modemSlot)
  3901.             T.drop()
  3902.            
  3903.             sleep(60)
  3904.            
  3905.             T.select(8)
  3906.             T.suckUp()
  3907.             T.transferTo(1, 1)
  3908.             T.transferTo(3, 1)
  3909.             T.transferTo(5, 1)
  3910.             T.transferTo(7, 1)
  3911.             T.transferTo(10, 1)
  3912.            
  3913.             local count, slots = T:LookInvItems("chest", true)
  3914.            
  3915.             T.select(slots[1])
  3916.             T.transferTo(6, 1)
  3917.             T.craft()
  3918.            
  3919.             T.select(modemSlot)
  3920.             T.suck()
  3921.            
  3922.             T.select(chestSlot)
  3923.             T.dig()
  3924.            
  3925.             T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  3926.             T:TurnDirection(T:getHomeR())
  3927.            
  3928.             SaveFile("log", "Placeing Hopper", true)
  3929.            
  3930.             T.select(slots[1])
  3931.             T:TurnLeft()
  3932.            
  3933.             for i = 1, 3 do
  3934.                
  3935.                 T:Forward()
  3936.                
  3937.             end
  3938.            
  3939.             for i = 1, 2 do
  3940.                
  3941.                 T:TurnLeft()
  3942.                
  3943.             end
  3944.            
  3945.             for i = 1, 2 do
  3946.                
  3947.                 T.digDown()
  3948.                 T:Down()
  3949.                 T.dig()
  3950.                
  3951.             end
  3952.            
  3953.             T.place()
  3954.            
  3955.             T:GoHome()
  3956.            
  3957.         else
  3958.            
  3959.             SaveFile("log", "Cant find iron chest", true)
  3960.             error()
  3961.            
  3962.         end
  3963.        
  3964.     else
  3965.        
  3966.         SaveFile("log", "Cant find wood chest", true)
  3967.         error()
  3968.        
  3969.     end
  3970.    
  3971. end
  3972.  
  3973. function MakeTorches()
  3974.    
  3975.     SaveFile("log", "Crafting torches", true)
  3976.    
  3977.     local number = T:findChest("wood")
  3978.    
  3979.     local sticks, planks, logs = false, false, false
  3980.    
  3981.     if number then
  3982.        
  3983.         T:GoTo(Chests[number])
  3984.         GetChest()
  3985.         T.select(chestSlot)
  3986.         T.placeUp()
  3987.        
  3988.         local chest1 = Per.wrap("bottom")
  3989.        
  3990.         local size1 = chest1.size()
  3991.        
  3992.         T.select(4)
  3993.        
  3994.         if not(sticks) then
  3995.            
  3996.             for i = 1, size1 do
  3997.                
  3998.                 local Details = chest1.getItemDetail(i)
  3999.                
  4000.                 if Details then
  4001.                    
  4002.                     if Details.count >= 1 and string.find(Details.name, "stick") and not(sticks) then
  4003.                        
  4004.                         chest1.pushItems("top", i, 1)
  4005.                         sticks = true
  4006.                        
  4007.                     end
  4008.                    
  4009.                 end
  4010.                
  4011.             end
  4012.            
  4013.         end
  4014.        
  4015.         if not(sticks) and not(planks) then
  4016.            
  4017.             for i = 1, size1 do
  4018.                
  4019.                 local Details = chest1.getItemDetail(i)
  4020.                
  4021.                 if Details then
  4022.                    
  4023.                     if Details.count >= 2 and string.find(Details.name, "planks") and not(sticks) and not(planks) then
  4024.                        
  4025.                         chest1.pushItems("top", i, 2)
  4026.                         planks = true
  4027.                        
  4028.                     end
  4029.                    
  4030.                 end
  4031.                
  4032.             end
  4033.            
  4034.         end
  4035.        
  4036.         if (sticks or planks) and not(logs) then
  4037.            
  4038.             for i = 1, size1 do
  4039.                
  4040.                 local Details = chest1.getItemDetail(i)
  4041.                
  4042.                 if Details then
  4043.                    
  4044.                     if Details.count >= 2 and string.find(Details.name, "log") and (sticks or planks) and not(logs) then
  4045.                        
  4046.                         chest1.pushItems("top", i, 2)
  4047.                         logs = true
  4048.                         break
  4049.                        
  4050.                     end
  4051.                    
  4052.                 end
  4053.                
  4054.             end
  4055.            
  4056.         end
  4057.        
  4058.         if not(sticks) and not(planks) and not(logs) then
  4059.            
  4060.             for i = 1, size1 do
  4061.                
  4062.                 local Details = chest1.getItemDetail(i)
  4063.                
  4064.                 if Details then
  4065.                    
  4066.                     if Details.count >= 3 and string.find(Details.name, "log") and not(sticks) and not(planks) and not(logs) then
  4067.                        
  4068.                         chest1.pushItems("top", i, 3)
  4069.                         logs = true
  4070.                         break
  4071.                        
  4072.                     end
  4073.                    
  4074.                 end
  4075.                
  4076.             end
  4077.            
  4078.         end
  4079.        
  4080.         while T.suckUp() do end
  4081.        
  4082.         T.select(chestSlot)
  4083.         T.digUp()
  4084.        
  4085.         local number, logsslots = T:LookInvItems("log", true)
  4086.        
  4087.         local Countt = T.getItemCount(4)
  4088.        
  4089.         if not(logs) then
  4090.            
  4091.             if Status >= 16 then
  4092.                
  4093.                 HarvestTreeFarm()
  4094.                 local stone, mess = T:GetItemFromChest("wood", "log", 3, 4)
  4095.                
  4096.             else
  4097.            
  4098.                 SaveFile("log", "Not enuf logs", true)
  4099.                 error()
  4100.                
  4101.             end
  4102.            
  4103.         end
  4104.        
  4105.         T:GoTo(Chests[1])
  4106.         T:TurnDirection(T.HomeR)
  4107.         T:Back()
  4108.        
  4109.         for i = 1, 2 do
  4110.            
  4111.             T:Up()
  4112.            
  4113.         end
  4114.        
  4115.         T:Forward()
  4116.         T.select(logsslots[1])
  4117.         T.dropDown(1)
  4118.         T:Back()
  4119.         T:Down()
  4120.         T.suck()
  4121.         T.drop(1)
  4122.         T:Down()
  4123.         T:Forward()
  4124.         GetChest()
  4125.         T.select(chestSlot)
  4126.         T.place()
  4127.         T.select(modemSlot)
  4128.         T.dropDown()
  4129.         T.select(bucketSlot)
  4130.         T.dropDown()
  4131.        
  4132.         if not(planks) and not(sticks) and logs then
  4133.            
  4134.             local number, stickslots = T:LookInvItems("log", true)
  4135.            
  4136.             for i = 1, 15 do
  4137.                
  4138.                 if i ~= stickslot[1] then
  4139.                     T.select(i)
  4140.                     T.dropDown()
  4141.                 end
  4142.                
  4143.             end
  4144.            
  4145.             T.select(logsslots[1])
  4146.             T.transferTo(1,1)
  4147.             T.dropDown()
  4148.             T.craft()
  4149.             planks = true
  4150.            
  4151.         end
  4152.        
  4153.         local number, planksslots = T:LookInvItems("planks", true)
  4154.        
  4155.         if not(sticks) and planks then
  4156.            
  4157.             local number, stickslots = T:LookInvItems("planks", true)
  4158.            
  4159.             for i = 1, 15 do
  4160.                
  4161.                 if i ~= stickslot[1] then
  4162.                     T.select(i)
  4163.                     T.dropDown()
  4164.                 end
  4165.                
  4166.             end
  4167.            
  4168.             T.select(planksslots[1])
  4169.             T.transferTo(1,1)
  4170.             T.transferTo(5,1)
  4171.             T.dropDown()
  4172.             T.craft()
  4173.             sticks = true
  4174.            
  4175.         end
  4176.        
  4177.         local number, stickslots = T:LookInvItems("stick", true)
  4178.        
  4179.         for i = 1, 15 do
  4180.            
  4181.             if i ~= stickslots[1] then
  4182.                 T.select(i)
  4183.                 T.dropDown()
  4184.             end
  4185.            
  4186.         end
  4187.        
  4188.         sleep(10)
  4189.        
  4190.         T.select(8)
  4191.         T.suckUp()
  4192.        
  4193.         if sticks then
  4194.            
  4195.             T.transferTo(1,1)
  4196.             T.dropDown()
  4197.            
  4198.             local number, sticksslots = T:LookInvItems("stick", true)
  4199.            
  4200.             if sticksslots[1] ~= 4 then
  4201.                
  4202.                 T.select(sticksslots[1])
  4203.                 T.transferTo(4,1)
  4204.                 T.dropDown()
  4205.                
  4206.             end
  4207.            
  4208.             T.select(4)
  4209.             T.transferTo(5,1)
  4210.             T.craft()
  4211.            
  4212.         else
  4213.            
  4214.             T.dropDown()
  4215.            
  4216.         end
  4217.        
  4218.         T.select(chestSlot)
  4219.         T.dig()
  4220.        
  4221.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  4222.         T:TurnDirection(T:getHomeR())
  4223.        
  4224.     else
  4225.        
  4226.         SaveFile("log", "Cant find wood chest", true)
  4227.         error()
  4228.        
  4229.     end
  4230.    
  4231. end
  4232.  
  4233. function MakeTreeFarm()
  4234.    
  4235.     GetModem()
  4236.    
  4237.     SaveFile("log", "Makeing Tree Farm", true)
  4238.    
  4239.     local torches = T:GetItemFromChest("wood", "torch", 4, 4)
  4240.    
  4241.     while not(torches) do
  4242.        
  4243.         MakeTorches()
  4244.         SortStorage()
  4245.         GetModem()
  4246.         GetBucket()
  4247.         torches = T:GetItemFromChest("wood", "torch", 4, 4)
  4248.        
  4249.     end
  4250.    
  4251.     local stone = T:GetItemFromChest("stone", "cobblestone", 64, 3)
  4252.    
  4253.     local dirt = T:GetItemFromChest("sand", "dirt", 4, 2)
  4254.    
  4255.     local sapling = T:GetItemFromChest("sapling", "sapling", 64, 1)
  4256.    
  4257.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  4258.     T:TurnDirection(T:getHomeR())
  4259.    
  4260.     if not(stone) then
  4261.        
  4262.         SaveFile("log", "Cant find stone", true)
  4263.         error()
  4264.        
  4265.     end
  4266.    
  4267.     if not(dirt) then
  4268.        
  4269.         SaveFile("log", "Cant find dirt", true)
  4270.         error()
  4271.        
  4272.     end
  4273.    
  4274.     if not(sapling) then
  4275.        
  4276.         SaveFile("log", "Cant find saplings", true)
  4277.         error()
  4278.        
  4279.     end
  4280.    
  4281.     SaveFile("log", "Found:", true)
  4282.     local Torchnumber, Torchslots = T:LookInvItems("torch", true)
  4283.     SaveFile("log", "Torchs: "..Torchnumber, true)
  4284.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4285.     SaveFile("log", "Cobblestone: "..Stonenumber, true)
  4286.     local Dirtnumber, Dirtslots = T:LookInvItems("dirt", true)
  4287.     SaveFile("log", "Dirt: "..Dirtnumber, true)
  4288.     local Saplingnumber, Saplingslots = T:LookInvItems("sapling", true)
  4289.     SaveFile("log", "Sapling: "..Saplingnumber, true)
  4290.    
  4291.    
  4292.     T:Forward()
  4293.     T:TurnLeft()
  4294.     T.select(Stoneslots[1])
  4295.    
  4296.     for I = 1, 3 do
  4297.         T.dig()
  4298.         sleep(0.5)
  4299.     end
  4300.    
  4301.     T:Forward()
  4302.     T.digDown()
  4303.     T:Down()
  4304.     T.digDown()
  4305.     T.placeDown()
  4306.    
  4307.     for I = 1, 3 do
  4308.         T.dig()
  4309.         sleep(0.5)
  4310.     end
  4311.    
  4312.     T:Forward()
  4313.    
  4314.     for I = 1, 2 do
  4315.        
  4316.         T:TurnRight()
  4317.        
  4318.     end
  4319.    
  4320.     T.place()
  4321.    
  4322.     for I = 1, 2 do
  4323.        
  4324.         T:TurnLeft()
  4325.        
  4326.     end
  4327.    
  4328.     for i = 1, 10 do
  4329.        
  4330.         T.digDown()
  4331.         T.placeDown()
  4332.        
  4333.         for I = 1, 3 do
  4334.             T.digUp()
  4335.             sleep(0.5)
  4336.         end
  4337.        
  4338.         T.placeUp()
  4339.        
  4340.         for I = 1, 3 do
  4341.             T.dig()
  4342.             sleep(0.5)
  4343.         end
  4344.        
  4345.         T:Forward()
  4346.        
  4347.         for I = 1, 2 do
  4348.            
  4349.             T:TurnRight()
  4350.            
  4351.         end
  4352.        
  4353.         T.place()
  4354.        
  4355.         for I = 1, 2 do
  4356.            
  4357.             T:TurnLeft()
  4358.            
  4359.         end
  4360.        
  4361.     end
  4362.    
  4363.     T:SortInvItems(2)
  4364.    
  4365.     local Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4366.    
  4367.     T.select(Stoneslots[1])
  4368.     T:TurnLeft()
  4369.    
  4370.     for I = 1, 3 do
  4371.         T.dig()
  4372.         sleep(0.5)
  4373.     end
  4374.    
  4375.     T:Forward()
  4376.     T:TurnLeft()
  4377.    
  4378.     local SSx, SSy, SSz = 0, 0, 0
  4379.    
  4380.     for i = 1, 9 do
  4381.        
  4382.         for I = 1, 3 do
  4383.             T.dig()
  4384.             sleep(0.5)
  4385.         end
  4386.        
  4387.         T:Forward()
  4388.        
  4389.         for I = 1, 3 do
  4390.             T.digUp()
  4391.             sleep(0.5)
  4392.         end
  4393.        
  4394.         T.digDown()
  4395.         T.placeDown()
  4396.        
  4397.         if i == 2 then
  4398.            
  4399.             SSx, SSy, SSz = T:getX(), (T:getY()+1), T:getZ()
  4400.            
  4401.         end
  4402.        
  4403.     end
  4404.    
  4405.     T:SortInvItems(2)
  4406.    
  4407.     local SX, SY, SZ, SR = T:getX(), T:getY(), T:getZ(), T:getR()
  4408.    
  4409.     T:GoHome()
  4410.    
  4411.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4412.    
  4413.     local stone = T:GetItemFromChest("stone", "cobblestone", 64, 3)
  4414.    
  4415.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  4416.     T:TurnDirection(T:getHomeR())
  4417.    
  4418.     if not(stone) then
  4419.        
  4420.         SaveFile("log", "Cant find stone", true)
  4421.         error()
  4422.        
  4423.     end
  4424.    
  4425.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4426.    
  4427.     T.select(Stoneslots[1])
  4428.     T:GoTo(SX, SY, SZ)
  4429.     T:TurnDirection(SR)
  4430.    
  4431.     for i = 1, 2 do
  4432.         T:Forward()
  4433.     end
  4434.    
  4435.     T:TurnRight()
  4436.    
  4437.     for I = 1, 3 do
  4438.         T.dig()
  4439.         sleep(0.5)
  4440.     end
  4441.    
  4442.     T:Forward()
  4443.     T:TurnRight()
  4444.    
  4445.     for I = 1, 3 do
  4446.         T.digUp()
  4447.         sleep(0.5)
  4448.     end
  4449.    
  4450.     T.placeUp()
  4451.     T.digDown()
  4452.     T.placeDown()
  4453.    
  4454.     for I = 1, 3 do
  4455.         T.dig()
  4456.         sleep(0.5)
  4457.     end
  4458.    
  4459.     T:Forward()
  4460.    
  4461.     for i = 1, 2 do
  4462.         T:TurnRight()
  4463.     end
  4464.    
  4465.     T.place()
  4466.    
  4467.     for i = 1, 2 do
  4468.         T:TurnLeft()
  4469.     end
  4470.    
  4471.     T.digDown()
  4472.     T.placeDown()
  4473.    
  4474.     for I = 1, 3 do
  4475.         T.digUp()
  4476.         sleep(0.5)
  4477.     end
  4478.    
  4479.     T:Up()
  4480.    
  4481.     for I = 1, 3 do
  4482.         T.digUp()
  4483.         sleep(0.5)
  4484.     end
  4485.    
  4486.     T.placeDown()
  4487.    
  4488.     T:SortInvItems(2)
  4489.    
  4490.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4491.    
  4492.     T.select(Stoneslots[1])
  4493.    
  4494.     for i = 1, 9 do
  4495.        
  4496.         for I = 1, 3 do
  4497.             T.dig()
  4498.             sleep(0.5)
  4499.         end
  4500.        
  4501.         T:Forward()
  4502.        
  4503.         for I = 1, 3 do
  4504.             T.digUp()
  4505.             sleep(0.5)
  4506.         end
  4507.        
  4508.         T.digDown()
  4509.         T.placeDown()
  4510.        
  4511.     end
  4512.    
  4513.     for I = 1, 3 do
  4514.         T.dig()
  4515.         sleep(0.5)
  4516.     end
  4517.    
  4518.     T:Forward()
  4519.    
  4520.     for I = 1, 3 do
  4521.         T.digUp()
  4522.         sleep(0.5)
  4523.     end
  4524.    
  4525.     for i = 1, 2 do
  4526.         T:TurnRight()
  4527.     end
  4528.    
  4529.     T.place()
  4530.    
  4531.     T:TurnLeft()
  4532.    
  4533.     for I = 1, 3 do
  4534.         T.digUp()
  4535.         sleep(0.5)
  4536.     end
  4537.    
  4538.     T:Forward()
  4539.    
  4540.     for I = 1, 3 do
  4541.         T.digUp()
  4542.         sleep(0.5)
  4543.     end
  4544.    
  4545.     T:TurnRight()
  4546.    
  4547.     for I = 1, 3 do
  4548.         T.dig()
  4549.         sleep(0.5)
  4550.     end
  4551.    
  4552.     T:Forward()
  4553.    
  4554.     for I = 1, 3 do
  4555.         T.digUp()
  4556.         sleep(0.5)
  4557.     end
  4558.    
  4559.     T.digDown()
  4560.     T.placeDown()
  4561.    
  4562.     T:Up()
  4563.    
  4564.     for I = 1, 3 do
  4565.         T.digUp()
  4566.         sleep(0.5)
  4567.     end
  4568.    
  4569.     T.placeDown()
  4570.    
  4571.     T:SortInvItems(2)
  4572.    
  4573.     SX, SY, SZ, SR = T:getX(), T:getY(), T:getZ(), T:getR()
  4574.    
  4575.     T:GoHome()
  4576.    
  4577.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4578.    
  4579.     local stone = T:GetItemFromChest("stone", "cobblestone", 64, 3)
  4580.    
  4581.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  4582.     T:TurnDirection(T:getHomeR())
  4583.    
  4584.     if not(stone) then
  4585.        
  4586.         SaveFile("log", "Cant find stone", true)
  4587.         error()
  4588.        
  4589.     end
  4590.    
  4591.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4592.    
  4593.     T.select(Stoneslots[1])
  4594.     T:GoTo(SX, SY, SZ)
  4595.     T:TurnDirection(SR)
  4596.    
  4597.     T:TurnRight()
  4598.    
  4599.     for i = 1, 9 do
  4600.         for I = 1, 3 do
  4601.             T.dig()
  4602.             sleep(0.5)
  4603.         end
  4604.         T:Forward()
  4605.         for I = 1, 3 do
  4606.             T.digUp()
  4607.             sleep(0.5)
  4608.         end
  4609.         T.digDown()
  4610.         T:Down()
  4611.         T.digDown()
  4612.         T.placeDown()
  4613.         T:Up()
  4614.         T.placeDown()
  4615.     end
  4616.    
  4617.     T:SortInvItems(2)
  4618.    
  4619.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4620.    
  4621.     T.select(Stoneslots[1])
  4622.    
  4623.     T:TurnLeft()
  4624.    
  4625.     for i = 1, 10 do
  4626.         for I = 1, 3 do
  4627.             T.dig()
  4628.             sleep(0.5)
  4629.         end
  4630.         T:Forward()
  4631.         for I = 1, 3 do
  4632.             T.digUp()
  4633.             sleep(0.5)
  4634.         end
  4635.         T.digDown()
  4636.         T:Down()
  4637.         T.digDown()
  4638.         T.placeDown()
  4639.         T:Up()
  4640.         T.placeDown()
  4641.     end
  4642.    
  4643.     T:TurnLeft()
  4644.    
  4645.     T:SortInvItems(2)
  4646.    
  4647.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4648.    
  4649.     T.select(Stoneslots[1])
  4650.    
  4651.     for i = 1, 8 do
  4652.         for I = 1, 3 do
  4653.             T.dig()
  4654.             sleep(0.5)
  4655.         end
  4656.         T:Forward()
  4657.         for I = 1, 3 do
  4658.             T.digUp()
  4659.             sleep(0.5)
  4660.         end
  4661.         T.digDown()
  4662.         T:Down()
  4663.         T.digDown()
  4664.         T.placeDown()
  4665.         T:Up()
  4666.         T.placeDown()
  4667.     end
  4668.    
  4669.     T:SortInvItems(2)
  4670.    
  4671.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4672.    
  4673.     T.select(Stoneslots[1])
  4674.    
  4675.     SX, SY, SZ, SR = T:getX(), T:getY(), T:getZ(), T:getR()
  4676.    
  4677.     T:GoHome()
  4678.    
  4679.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4680.    
  4681.     local stone = T:GetItemFromChest("stone", "cobblestone", 64, 3)
  4682.    
  4683.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  4684.     T:TurnDirection(T:getHomeR())
  4685.    
  4686.     if not(stone) then
  4687.        
  4688.         SaveFile("log", "Cant find stone", true)
  4689.         error()
  4690.        
  4691.     end
  4692.    
  4693.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  4694.    
  4695.     T.select(Stoneslots[1])
  4696.     T:GoTo(SX, SY, SZ)
  4697.     T:TurnDirection(SR)
  4698.    
  4699.     T:Back()
  4700.     T:TurnLeft()
  4701.     T:Forward()
  4702.     T.digDown()
  4703.     T:Down()
  4704.     T.digDown()
  4705.     T.placeDown()
  4706.    
  4707.     for I = 1, 7 do
  4708.        
  4709.         for i = 1, 8 do
  4710.            
  4711.             for l = 1, 3 do
  4712.                 T.dig()
  4713.                 sleep(0.5)
  4714.             end
  4715.            
  4716.             T:Forward()
  4717.             T.digUp()
  4718.             T.digDown()
  4719.             T.placeDown()
  4720.            
  4721.         end
  4722.        
  4723.         if (I%2) == 1 and I < 7 then
  4724.            
  4725.             T:TurnLeft()
  4726.            
  4727.             for l = 1, 3 do
  4728.                 T.dig()
  4729.                 sleep(0.5)
  4730.             end
  4731.            
  4732.             T:Forward()
  4733.             T.digUp()
  4734.             T.digDown()
  4735.             T.placeDown()
  4736.             T:TurnLeft()
  4737.            
  4738.         elseif I < 7 then
  4739.            
  4740.             T:TurnRight()
  4741.            
  4742.             for l = 1, 3 do
  4743.                 T.dig()
  4744.                 sleep(0.5)
  4745.             end
  4746.            
  4747.             T:Forward()
  4748.             T.digUp()
  4749.             T.digDown()
  4750.             T.placeDown()
  4751.             T:TurnRight()
  4752.            
  4753.         end
  4754.        
  4755.     end
  4756.    
  4757.     T:SortInvItems(2)
  4758.    
  4759.     T:Up()
  4760.    
  4761.     T.select(bucketSlot)
  4762.    
  4763.     if not(Water.found) then
  4764.        
  4765.         SaveFile("log", "No water found", true)
  4766.         error()
  4767.        
  4768.     end
  4769.    
  4770.     for i = 1, 9 do
  4771.        
  4772.         SX, SY, SZ, SR = T:getX(), T:getY(), T:getZ(), T:getR()
  4773.        
  4774.         T:GoTo(Water.x, SY, Water.z)
  4775.        
  4776.         T:GoTo(Water.x, Water.y, Water.z)
  4777.        
  4778.         while not(T.inspectDown()) do
  4779.            
  4780.             T:Down()
  4781.            
  4782.         end
  4783.        
  4784.         local succes, data = T.inspectDown()
  4785.        
  4786.         if succes then
  4787.            
  4788.             local a = 2
  4789.            
  4790.             if not(string.find(data.name, "water")) then
  4791.                
  4792.                 T:Forward()
  4793.                
  4794.             end
  4795.            
  4796.             if not(string.find(data.name, "water")) then
  4797.                
  4798.                 T:TurnRight()
  4799.                 T:Forward()
  4800.                
  4801.             end
  4802.            
  4803.             if not(string.find(data.name, "water")) then
  4804.                
  4805.                 T:TurnRight()
  4806.                
  4807.                 for i = 1, a do
  4808.                    
  4809.                     T:Forward()
  4810.                    
  4811.                 end
  4812.                
  4813.             end
  4814.            
  4815.             if not(string.find(data.name, "water")) then
  4816.                
  4817.                 T:TurnRight()
  4818.                
  4819.                 for i = 1, a do
  4820.                    
  4821.                     T:Forward()
  4822.                    
  4823.                 end
  4824.                
  4825.             end
  4826.            
  4827.             a = a + 1
  4828.            
  4829.             if not(string.find(data.name, "water")) then
  4830.                
  4831.                 T:TurnRight()
  4832.                
  4833.                 for i = 1, a do
  4834.                    
  4835.                     T:Forward()
  4836.                    
  4837.                 end
  4838.                
  4839.             end
  4840.            
  4841.             if not(string.find(data.name, "water")) then
  4842.                
  4843.                 T:TurnRight()
  4844.                
  4845.                 for i = 1, a do
  4846.                    
  4847.                     T:Forward()
  4848.                    
  4849.                 end
  4850.                
  4851.             end
  4852.            
  4853.             a = a + 1
  4854.            
  4855.             if not(string.find(data.name, "water")) then
  4856.                
  4857.                 T:TurnRight()
  4858.                
  4859.                 for i = 1, a do
  4860.                    
  4861.                     T:Forward()
  4862.                    
  4863.                 end
  4864.                
  4865.             end
  4866.            
  4867.             if not(string.find(data.name, "water")) then
  4868.                
  4869.                 T:TurnRight()
  4870.                
  4871.                 for i = 1, a do
  4872.                    
  4873.                     T:Forward()
  4874.                    
  4875.                 end
  4876.                
  4877.             end
  4878.            
  4879.             a = a + 1
  4880.            
  4881.             if not(string.find(data.name, "water")) then
  4882.                
  4883.                 T:TurnRight()
  4884.                
  4885.                 for i = 1, a do
  4886.                    
  4887.                     T:Forward()
  4888.                    
  4889.                 end
  4890.                
  4891.             end
  4892.            
  4893.             if not(string.find(data.name, "water")) then
  4894.                
  4895.                 T:TurnRight()
  4896.                
  4897.                 for i = 1, a do
  4898.                    
  4899.                     T:Forward()
  4900.                    
  4901.                 end
  4902.                
  4903.             end
  4904.            
  4905.             a = a + 1
  4906.            
  4907.             if not(string.find(data.name, "water")) then
  4908.                
  4909.                 T:TurnRight()
  4910.                
  4911.                 for i = 1, a do
  4912.                    
  4913.                     T:Forward()
  4914.                    
  4915.                 end
  4916.                
  4917.             end
  4918.            
  4919.             if not(string.find(data.name, "water")) then
  4920.                
  4921.                 T:TurnRight()
  4922.                
  4923.                 for i = 1, a do
  4924.                    
  4925.                     T:Forward()
  4926.                    
  4927.                 end
  4928.                
  4929.             end
  4930.            
  4931.             if string.find(data.name, "water") then
  4932.                
  4933.                 Water.x, Water.y, Water.z = T:getX(), T:getY(), T:getZ()
  4934.                 SaveFile("locations")
  4935.                 T.placeDown()
  4936.                
  4937.             end
  4938.            
  4939.         end
  4940.        
  4941.         T:GoTo(SX, SY, SZ)
  4942.         T:TurnDirection(SR)
  4943.        
  4944.         T.placeDown()
  4945.        
  4946.         T:Back()
  4947.        
  4948.     end
  4949.    
  4950.     T.select(Dirtslots[1])
  4951.    
  4952.     for i = 1, 3 do
  4953.        
  4954.         T.dig()
  4955.         T:Forward()
  4956.         T.dig()
  4957.        
  4958.     end
  4959.    
  4960.     T:TurnRight()
  4961.     T.dig()
  4962.     T:Forward()
  4963.     T.dig()
  4964.     T.place()
  4965.     T.select(Saplingslots[1])
  4966.     T.digUp()
  4967.     T:Up()
  4968.     T.dig()
  4969.     T.place()
  4970.     T:Down()
  4971.     T:Back()
  4972.     T.select(Torchslots[1])
  4973.     T.place()
  4974.    
  4975.    
  4976.     for I = 1, 3 do
  4977.        
  4978.         T.select(Dirtslots[1])
  4979.         T:TurnLeft()
  4980.        
  4981.         for i = 1, 4 do
  4982.            
  4983.             T.dig()
  4984.             T:Forward()
  4985.             T.dig()
  4986.            
  4987.         end
  4988.        
  4989.         T:TurnRight()
  4990.        
  4991.         for i = 1, 2 do
  4992.            
  4993.             T.dig()
  4994.             T:Forward()
  4995.             T.dig()
  4996.            
  4997.         end
  4998.        
  4999.         T:TurnRight()
  5000.         T.dig()
  5001.         T.place()
  5002.         T.select(Saplingslots[1])
  5003.         T.digUp()
  5004.         T:Up()
  5005.         T.dig()
  5006.         T.place()
  5007.         T:Down()
  5008.         T:Back()
  5009.         T.select(Torchslots[1])
  5010.         T.place()
  5011.        
  5012.     end
  5013.    
  5014.     T.select(bucketSlot)
  5015.    
  5016.     T:GoTo(Water.x, (T:getY()+1), Water.z)
  5017.     T:GoTo(Water.x, Water.y, Water.z)
  5018.     T.placeDown()
  5019.     T:GoTo(SSx, (SSy+1), SSz)
  5020.     T:GoTo(SSx, SSy, SSz)
  5021.     T.placeDown()
  5022.    
  5023.     T.select(1)
  5024.    
  5025.     T:GoHome()
  5026.    
  5027.     T:emptyInv()
  5028.    
  5029.     Status = 8
  5030.    
  5031.     SaveFile("status")
  5032.    
  5033. end
  5034.  
  5035. function HarvestTreeFarm()
  5036.    
  5037.     local sapling, mess = T:GetItemFromChest("sapling", "sapling", 4, 1)
  5038.    
  5039.     if not(sapling) then
  5040.        
  5041.         SaveFile("log", mess, true)
  5042.         error()
  5043.        
  5044.     end
  5045.    
  5046.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  5047.     T:TurnDirection(T:getHomeR())
  5048.    
  5049.     for i = 1, 3 do
  5050.         T:Back()
  5051.     end
  5052.    
  5053.     for i = 1, 2 do
  5054.         T:Up()
  5055.     end
  5056.    
  5057.     T:TurnLeft()
  5058.    
  5059.     for i = 1, 3 do
  5060.         T:Forward()
  5061.     end
  5062.    
  5063.     T.select(1)
  5064.    
  5065.     HarvestTrees(2)
  5066.    
  5067.     for i = 1, 2 do
  5068.         T:Forward()
  5069.     end
  5070.    
  5071.     for i = 1, 2 do
  5072.         T:TurnLeft()
  5073.     end
  5074.    
  5075.     local saplingnumber, saplingslots = T:LookInvItems("sapling", true)
  5076.    
  5077.     T.select(saplingslots[1])
  5078.    
  5079.     T.place()
  5080.    
  5081.     T.select(1)
  5082.    
  5083.     for i = 1, 2 do
  5084.         T:TurnRight()
  5085.     end
  5086.    
  5087.     T:Forward()
  5088.    
  5089.     for i = 1, 2 do
  5090.         HarvestTrees(2)
  5091.         T:Forward()
  5092.         T:TurnLeft()
  5093.         T:Forward()
  5094.        
  5095.         for i = 1, 2 do
  5096.         T:TurnLeft()
  5097.         end
  5098.        
  5099.         saplingnumber, saplingslots = T:LookInvItems("sapling", true)
  5100.        
  5101.         T.select(saplingslots[1])
  5102.        
  5103.         T.place()
  5104.        
  5105.         T.select(1)
  5106.        
  5107.         for i = 1, 2 do
  5108.             T:TurnRight()
  5109.         end
  5110.        
  5111.         T:Forward()
  5112.     end
  5113.    
  5114.     HarvestTrees(2)
  5115.    
  5116.     for i = 1, 2 do
  5117.         T:Forward()
  5118.     end
  5119.    
  5120.     for i = 1, 2 do
  5121.         T:TurnLeft()
  5122.     end
  5123.    
  5124.     T.place()
  5125.    
  5126.     for i = 1, 2 do
  5127.         T:TurnRight()
  5128.     end
  5129.    
  5130.     for i = 1, 2 do
  5131.         T:Forward()
  5132.     end
  5133.    
  5134.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  5135.     T:TurnDirection(T:getHomeR())
  5136.    
  5137.     SortStorage()
  5138.    
  5139. end
  5140.  
  5141. function MineNow()
  5142.    
  5143.     SaveFile("log", "Mine Front", true)
  5144.    
  5145.     local Ro = T:getR()
  5146.    
  5147.     for i = 1, 36 do
  5148.         checkForOre()
  5149.         while T.dig() do end
  5150.         while T.digUp() do end
  5151.         T.digDown()
  5152.         T:Forward()
  5153.     end
  5154.    
  5155.     T:SortInvItems(1)
  5156.    
  5157.     checkForOre()
  5158.    
  5159.     T:SortInvItems(1)
  5160.    
  5161.     for I = 1, 18 do
  5162.        
  5163.         T:TurnLeft()
  5164.        
  5165.         SaveFile("log", "Mine Left", true)
  5166.        
  5167.         for i = 1, 18 do
  5168.             checkForOre()
  5169.             while T.dig() do end
  5170.             while T.digUp()do end
  5171.             T.digDown()
  5172.             T:Forward()
  5173.         end
  5174.        
  5175.         checkForOre()
  5176.         while T.digUp() do end
  5177.         T.digDown()
  5178.        
  5179.         SaveFile("log", "Back up", true)
  5180.        
  5181.         for i = 1, 18 do
  5182.             T:Back()
  5183.         end
  5184.        
  5185.         for i = 1,2 do
  5186.             T:TurnRight()
  5187.         end
  5188.        
  5189.         SaveFile("log", "Mine Right", true)
  5190.        
  5191.         for i = 1, 18 do
  5192.             checkForOre()
  5193.             while T.dig() do end
  5194.             while T.digUp()do end
  5195.             T.digDown()
  5196.             T:Forward()
  5197.         end
  5198.        
  5199.         checkForOre()
  5200.         while T.digUp() do end
  5201.         T.digDown()
  5202.        
  5203.         SaveFile("log", "Back up", true)
  5204.        
  5205.         for i = 1, 18 do
  5206.             T:Back()
  5207.         end
  5208.        
  5209.         T:TurnLeft()
  5210.        
  5211.         SaveFile("log", "Back up", true)
  5212.        
  5213.         for i = 1, 2 do
  5214.             checkForOre()
  5215.             T:Back()
  5216.         end
  5217.        
  5218.         T:SortInvItems(1)
  5219.        
  5220.     end
  5221.    
  5222.     T:GoTo(Mine.x, T:getY(), Mine.z)
  5223.     T:TurnDirection(Ro)
  5224.    
  5225. end
  5226.  
  5227. function GoMine(N)
  5228.    
  5229.     GetBucket()
  5230.     GetModem()
  5231.    
  5232.     if not(Mine.found) then
  5233.        
  5234.         local number = T:findChest("diamond")
  5235.        
  5236.         if number then
  5237.            
  5238.             T:GoTo(Chests[number])
  5239.            
  5240.             for i = 1, 2 do
  5241.                 T.dig()
  5242.                 T:Forward()
  5243.             end
  5244.            
  5245.             Mine.x, Mine.y, Mine.z = T:getX(), T:getY(), T:getZ()
  5246.             Mine.found = true
  5247.            
  5248.             SaveFile("locations")
  5249.            
  5250.             T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  5251.             T:TurnDirection(T:getHomeR())
  5252.            
  5253.         else
  5254.            
  5255.             SaveFile("log", "Cant find diamond chest", true)
  5256.             error()
  5257.            
  5258.         end
  5259.        
  5260.     end
  5261.    
  5262.     local A = 20
  5263.    
  5264.     if N == 2 then
  5265.         A = T:Add(A,1)
  5266.     elseif N == 3 then
  5267.         A = T:Sub(A,1)
  5268.     end
  5269.    
  5270.     SaveFile("log", "Makeing Mine Shaft", true)
  5271.    
  5272.     T:Refuel()
  5273.    
  5274.     T:GoTo(Mine.x, Mine.y, Mine.z)
  5275.    
  5276.     T.select(1)
  5277.    
  5278.     if A == 20 then
  5279.         while T.digUp() do end
  5280.         T:Up()
  5281.         while T.detectUp() do
  5282.             while T.digUp() do end
  5283.             T:Up()
  5284.         end
  5285.         while T.digUp() do end
  5286.     end
  5287.    
  5288.     while T:getY() > A do
  5289.         checkForOre()
  5290.         T.digDown()
  5291.         T:Down()
  5292.     end
  5293.    
  5294.     for i = 1, 2 do
  5295.         T:TurnLeft()
  5296.     end
  5297.    
  5298.     local RS = T:getR()
  5299.    
  5300.     T:SortInvItems(1)
  5301.    
  5302.     SaveFile("log", "Mine Layer "..A, true)
  5303.    
  5304.     MineNow()
  5305.    
  5306.     T:SortInvItems(1)
  5307.     T:GoHome()
  5308.     SortStorage()
  5309.     T:Refuel()
  5310.     GetBucket()
  5311.     GetModem()
  5312.     T:GoTo(Mine.x, Mine.y, Mine.z)
  5313.    
  5314.     A = T:Sub(A,3)
  5315.    
  5316.     for o = 1, 3 do
  5317.        
  5318.         while T:getY() > A do
  5319.             checkForOre()
  5320.             T.digDown()
  5321.             T:Down()
  5322.         end
  5323.        
  5324.         T:TurnDirection(RS)
  5325.        
  5326.         T:SortInvItems(1)
  5327.        
  5328.         SaveFile("log", "Mine Layer "..A, true)
  5329.        
  5330.         MineNow()
  5331.        
  5332.         T:SortInvItems(1)
  5333.         T:GoHome()
  5334.         SortStorage()
  5335.         T:Refuel()
  5336.         GetBucket()
  5337.         GetModem()
  5338.         T:GoTo(Mine.x, Mine.y, Mine.z)
  5339.        
  5340.         A = T:Sub(A,3)
  5341.        
  5342.     end
  5343.    
  5344.     while T:getY() > A do
  5345.         checkForOre()
  5346.         T.digDown()
  5347.         T:Down()
  5348.     end
  5349.    
  5350.     T:TurnDirection(RS)
  5351.    
  5352.     T:SortInvItems(1)
  5353.    
  5354.     SaveFile("log", "Mine Layer "..A, true)
  5355.    
  5356.     MineNow()
  5357.    
  5358.     T:SortInvItems(1)
  5359.    
  5360.     T:GoHome()
  5361.    
  5362.     SortStorage()
  5363.    
  5364.     GetBucket()
  5365.     GetModem()
  5366.    
  5367.     if A == 8 then
  5368.        
  5369.         local stone = T:GetItemFromChest("stone", "cobblestone", 64, 1)
  5370.        
  5371.         if stone then
  5372.            
  5373.             T:GoTo(Mine.x, Mine.y, Mine.z)
  5374.             T.select(1)
  5375.             while T.digUp() do end
  5376.             while T.dig() do end
  5377.             T:Forward()
  5378.             while T.digUp() do end
  5379.             T.digDown()
  5380.             T.placeDown()
  5381.             T:TurnLeft()
  5382.             while T.dig() do end
  5383.             T:Forward()
  5384.             while T.digUp() do end
  5385.             T.digDown()
  5386.             T.placeDown()
  5387.             T:Back()
  5388.            
  5389.             for i = 1, 2 do
  5390.                 T:TurnRight()
  5391.             end
  5392.            
  5393.             while T.dig() do end
  5394.             T:Forward()
  5395.             while T.digUp() do end
  5396.             T.digDown()
  5397.             T.placeDown()
  5398.             T:Back()
  5399.             T:TurnLeft()
  5400.             T:Back()
  5401.             T:TurnLeft()
  5402.             while T.dig() do end
  5403.             T:Forward()
  5404.             while T.digUp() do end
  5405.             T.digDown()
  5406.             T.placeDown()
  5407.             T:Back()
  5408.            
  5409.             for i = 1, 2 do
  5410.                 T:TurnRight()
  5411.             end
  5412.            
  5413.             while T.dig() do end
  5414.             T:Forward()
  5415.             while T.digUp() do end
  5416.             T.digDown()
  5417.             T.placeDown()
  5418.             T:Back()
  5419.             T:TurnLeft()
  5420.            
  5421.         else
  5422.            
  5423.             SaveFile("log", "Cant find stone", true)
  5424.             error()
  5425.            
  5426.         end
  5427.        
  5428.     end
  5429.    
  5430.     T:GoHome()
  5431.     SortStorage()
  5432.     T:Refuel()
  5433.     GetBucket()
  5434.     GetModem()
  5435.    
  5436.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  5437.     T:TurnDirection(T:getHomeR())
  5438.    
  5439.     if A == 8 then
  5440.         Status = 9
  5441.     elseif A == 9 then
  5442.         Status = 10
  5443.     end
  5444.    
  5445.     SaveFile("status")
  5446.    
  5447. end
  5448.  
  5449. function MakeGenerate()
  5450.    
  5451.     SaveFile("log", "Makeing cobblestone generator", true)
  5452.    
  5453.     GetBucket()
  5454.    
  5455.     local stone, mess = T:GetItemFromChest("stone", "cobblestone", 57, 1)
  5456.    
  5457.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  5458.     T:TurnDirection(T:getHomeR())
  5459.    
  5460.     for i = 1, 3 do T:Forward() end
  5461.    
  5462.     T:TurnLeft()
  5463.    
  5464.     for i = 1, 2 do T:Forward() end
  5465.    
  5466.     local stonecount, stoneslots = T:LookInvItems("cobblestone", true)
  5467.     local bucketcount, bucketslots = T:LookInvItems("bucket", true)
  5468.    
  5469.     if bucketcount == 0 then
  5470.         SaveFile("log", "Cant find lava_bucket", true)
  5471.         error()
  5472.     end
  5473.    
  5474.     T.select(stoneslots[1])
  5475.     T:TurnLeft()
  5476.     T:Forward()
  5477.     T:Up()
  5478.     T.place()
  5479.     T:TurnRight()
  5480.    
  5481.     for i = 1, 2 do
  5482.        
  5483.         T:Forward()
  5484.         T:TurnLeft()
  5485.         T.place()
  5486.         T:TurnRight()
  5487.        
  5488.     end
  5489.    
  5490.     T:Up()
  5491.     T:TurnRight()
  5492.    
  5493.     for i = 1, 5 do
  5494.        
  5495.         T:Down()
  5496.         T.digDown()
  5497.         T:Down()
  5498.         T.digDown()
  5499.         T:Down()
  5500.         T.digDown()
  5501.         T.placeDown()
  5502.         T:Up()
  5503.         T.placeDown()
  5504.         T:Up()
  5505.         T.placeDown()
  5506.         T:Up()
  5507.         T.placeDown()
  5508.        
  5509.         if i < 5 then
  5510.             T:Forward()
  5511.         end
  5512.        
  5513.     end
  5514.    
  5515.     T:TurnRight()
  5516.    
  5517.     for i = 1, 2 do T:Forward() end
  5518.    
  5519.     T:TurnRight()
  5520.    
  5521.     for i = 1, 5 do
  5522.        
  5523.         T:Down()
  5524.         T.digDown()
  5525.         T:Down()
  5526.         T.digDown()
  5527.         T:Down()
  5528.         T.digDown()
  5529.         T.placeDown()
  5530.         T:Up()
  5531.         T.placeDown()
  5532.         T:Up()
  5533.         if i ~= 4 then
  5534.             T.placeDown()
  5535.         end
  5536.         T:Up()
  5537.         T.placeDown()
  5538.        
  5539.         if i < 5 then
  5540.             T:Forward()
  5541.         end
  5542.        
  5543.     end
  5544.    
  5545.     for i = 1, 4 do T:Back() end
  5546.    
  5547.     T:TurnRight()
  5548.     T:Forward()
  5549.     T:TurnLeft()
  5550.    
  5551.     T:Down()
  5552.     T.digDown()
  5553.     T:Down()
  5554.     T.digDown()
  5555.     T:Down()
  5556.     T.digDown()
  5557.     T.placeDown()
  5558.     T:Up()
  5559.     T.placeDown()
  5560.     T:Up()
  5561.     T.placeDown()
  5562.     T:Up()
  5563.     T.placeDown()
  5564.     T:Forward()
  5565.    
  5566.     T:Down()
  5567.     T.digDown()
  5568.     T:Down()
  5569.     T.digDown()
  5570.     T:Down()
  5571.     T.digDown()
  5572.     T.placeDown()
  5573.     T:Up()
  5574.     T.placeDown()
  5575.     T:Up()
  5576.     T:Up()
  5577.     T:Forward()
  5578.    
  5579.     T:Down()
  5580.     T.digDown()
  5581.     T:Down()
  5582.     T.digDown()
  5583.     T:Down()
  5584.     T.digDown()
  5585.     T.placeDown()
  5586.     T:Up()
  5587.     T:Up()
  5588.     T:Up()
  5589.     T.placeDown()
  5590.     T:Forward()
  5591.    
  5592.     T:Down()
  5593.     T.digDown()
  5594.     T:Down()
  5595.     T.digDown()
  5596.     T:Down()
  5597.     T.digDown()
  5598.     T.placeDown()
  5599.     T:Up()
  5600.     T:Up()
  5601.     T:Up()
  5602.     T.placeDown()
  5603.     T:Forward()
  5604.    
  5605.     T:Down()
  5606.     T.digDown()
  5607.     T:Down()
  5608.     T.digDown()
  5609.     T:Down()
  5610.     T.digDown()
  5611.     T.placeDown()
  5612.     T:Up()
  5613.     T.placeDown()
  5614.     T:Up()
  5615.     T.select(bucketslots[1])
  5616.     T.placeDown()
  5617.     T:Up()
  5618.     T.select(stoneslots[1])
  5619.     T.placeDown()
  5620.    
  5621.     for i = 1, 3 do T:Back() end
  5622.    
  5623.     local sx, sy, sz, sr = T:getX(), T:getY(), T:getZ(), T:getR()
  5624.    
  5625.     T:GoTo(Water.x, sy, Water.z)
  5626.    
  5627.     T:GoTo(Water.x, Water.y, Water.z)
  5628.    
  5629.     T.select(bucketslots[1])
  5630.     T.placeDown()
  5631.    
  5632.     T:GoTo(sx, sy, sz)
  5633.     T:TurnDirection(sr)
  5634.     T:Down()
  5635.     T.placeDown()
  5636.     T:Up()
  5637.     T.select(stoneslots[1])
  5638.     T.placeDown()
  5639.    
  5640. end
  5641.  
  5642. function Generate(count, slot)
  5643.    
  5644.     if T:getLava() then
  5645.        
  5646.         SaveFile("log", "Getting cobblestone from generator", true)
  5647.        
  5648.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  5649.         T:TurnDirection(T:getHomeR())
  5650.        
  5651.         for i = 1, 3 do T:Forward() end
  5652.        
  5653.         T:TurnLeft()
  5654.        
  5655.         for i = 1, 2 do T:Forward() end
  5656.        
  5657.         T.select(slot)
  5658.        
  5659.         while T.getItemCount(slot) < count do T.dig() end
  5660.        
  5661.         for i = 1, 2 do T:Back() end
  5662.        
  5663.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  5664.         T:TurnDirection(T:getHomeR())
  5665.        
  5666.     else
  5667.        
  5668.         SaveFile("log", "No lava found", true)
  5669.         error()
  5670.        
  5671.     end
  5672.    
  5673. end
  5674.  
  5675. function FixMine(N)
  5676.    
  5677.     local a = 22
  5678.     if N == 2 then
  5679.         a = 17
  5680.     elseif N == 3 then
  5681.         a = 12
  5682.     end
  5683.    
  5684.     GetModem()
  5685.    
  5686.     SaveFile("log", "Getting stone", true)
  5687.    
  5688.     local Stone, mess = T:GetItemFromChest("stone", "cobblestone", 63, 1)
  5689.    
  5690.     if not(Stone) then
  5691.        
  5692.         Generate(63, 1)
  5693.        
  5694.     end
  5695.    
  5696.     T:GoTo(Mine.x, Mine.y, Mine.z)
  5697.    
  5698.     while T:getY() > a do
  5699.         T:Down()
  5700.     end
  5701.    
  5702.     for i = 1, 2 do
  5703.         T:TurnLeft()
  5704.     end
  5705.    
  5706.     while T:getY() >= (a-5) do
  5707.        
  5708.         for i = 1, 36 do
  5709.             T:Forward()
  5710.         end
  5711.        
  5712.         for I = 1, 18 do
  5713.            
  5714.             T.select(1)
  5715.            
  5716.             T:TurnLeft()
  5717.            
  5718.             SaveFile("log", "Fixing Mine Left", true)
  5719.            
  5720.             for i = 1, 18 do
  5721.                 T.dig()
  5722.                 T:Forward()
  5723.                 T.select(1)
  5724.                
  5725.                 if T:getY() == 22 then
  5726.                     while T.digUp()do end
  5727.                     T.placeUp()
  5728.                 end
  5729.                
  5730.                 T:TurnRight()
  5731.                 T.dig()
  5732.                 T.place()
  5733.                
  5734.                 if I == 18 then
  5735.                     for i = 1, 2 do
  5736.                         T:TurnLeft()
  5737.                     end
  5738.                    
  5739.                     T.dig()
  5740.                     T.place()
  5741.                     T:TurnRight()
  5742.                 else
  5743.                     T:TurnLeft()
  5744.                 end
  5745.             end
  5746.            
  5747.             T.dig()
  5748.             T.place()
  5749.            
  5750.             SaveFile("log", "Back up", true)
  5751.            
  5752.             for i = 1, 18 do
  5753.                 T:Back()
  5754.             end
  5755.            
  5756.             T:SortInvItems(1)
  5757.            
  5758.             local count, slots = T:LookInvItems("cobblestone", true)
  5759.            
  5760.             if count < 38 then
  5761.                
  5762.                 local sx, sy, sz, sr = T:getX(), T:getY(), T:getZ(), T:getR()
  5763.                
  5764.                 T:GoTo(Mine.x, sy, Mine.z)
  5765.                 T:GoTo(Mine.x, Mine.y, Mine.z)
  5766.                
  5767.                 SortStorage(2)
  5768.                
  5769.                 T:Refuel()
  5770.                
  5771.                 GetModem()
  5772.                
  5773.                 Stone, mess = T:GetItemFromChest("stone", "cobblestone", 63, 1)
  5774.                
  5775.                 if not(Stone) then
  5776.                    
  5777.                     Generate(63, 1)
  5778.                    
  5779.                 end
  5780.                
  5781.                 T:GoTo(Mine.x, Mine.y, Mine.z)
  5782.                 T:GoTo(Mine.x, sy, Mine.z)
  5783.                 T:GoTo(sx, sy, sz)
  5784.                 T:TurnDirection(sr)
  5785.                
  5786.             end
  5787.            
  5788.             for i = 1,2 do
  5789.                 T:TurnRight()
  5790.             end
  5791.            
  5792.             SaveFile("log", "Fixing Mine Right", true)
  5793.            
  5794.             for i = 1, 18 do
  5795.                 T.dig()
  5796.                 T:Forward()
  5797.                 T.select(1)
  5798.                
  5799.                 if T:getY() == 22 then
  5800.                     while T.digUp()do end
  5801.                     T.placeUp()
  5802.                 end
  5803.                
  5804.                 T:TurnLeft()
  5805.                 T.dig()
  5806.                 T.place()
  5807.                
  5808.                 if I == 18 then
  5809.                     for i = 1, 2 do
  5810.                         T:TurnRight()
  5811.                     end
  5812.                    
  5813.                     T.dig()
  5814.                     T.place()
  5815.                     T:TurnLeft()
  5816.                 else
  5817.                     T:TurnRight()
  5818.                 end
  5819.             end
  5820.            
  5821.             T.dig()
  5822.             T.place()
  5823.            
  5824.             SaveFile("log", "Back up", true)
  5825.            
  5826.             for i = 1, 18 do
  5827.                 T:Back()
  5828.             end
  5829.            
  5830.             T:TurnLeft()
  5831.            
  5832.             if I == 1 then
  5833.                
  5834.                 T.dig()
  5835.                 T.place()
  5836.                
  5837.             end
  5838.            
  5839.             SaveFile("log", "Back up", true)
  5840.            
  5841.             for i = 1, 2 do
  5842.                 T.select(1)
  5843.                
  5844.                 if T:getY() == 22 then
  5845.                     while T.digUp()do end
  5846.                     T.placeUp()
  5847.                 end
  5848.                
  5849.                 T:Back()
  5850.             end
  5851.            
  5852.             T:SortInvItems(1)
  5853.            
  5854.             count, slots = T:LookInvItems("cobblestone", true)
  5855.            
  5856.             if count < 38 and I < 18 then
  5857.                
  5858.                 local sx, sy, sz, sr = T:getX(), T:getY(), T:getZ(), T:getR()
  5859.                
  5860.                 T:GoTo(Mine.x, sy, Mine.z)
  5861.                 T:GoTo(Mine.x, Mine.y, Mine.z)
  5862.                
  5863.                 SortStorage(2)
  5864.                
  5865.                 T:Refuel()
  5866.                
  5867.                 GetModem()
  5868.                
  5869.                 Stone, mess = T:GetItemFromChest("stone", "cobblestone", 63, 1)
  5870.                
  5871.                 if not(Stone) then
  5872.                    
  5873.                     Generate(63, 1)
  5874.                    
  5875.                 end
  5876.                
  5877.                 T:GoTo(Mine.x, Mine.y, Mine.z)
  5878.                 T:GoTo(Mine.x, sy, Mine.z)
  5879.                 T:GoTo(sx, sy, sz)
  5880.                 T:TurnDirection(sr)
  5881.                
  5882.             end
  5883.            
  5884.         end
  5885.        
  5886.         T:Down()
  5887.        
  5888.     end
  5889.    
  5890.     T:GoHome()
  5891.     SortStorage()
  5892.     T:Refuel()
  5893.     GetModem()
  5894.    
  5895.     if N == 1 then
  5896.         Status = 12
  5897.     elseif N == 2 then
  5898.         Status = 13
  5899.     elseif N == 3 then
  5900.         Status = 14
  5901.     end
  5902.    
  5903.     SaveFile("status")
  5904.    
  5905. end
  5906.  
  5907. function MakeSword(N)
  5908.    
  5909.     SaveFile("log", "Making Sword", true)
  5910.    
  5911.     local stick, mess = T:GetItemFromChest("wood", "stick", 1, 9)
  5912.     local craft = false
  5913.    
  5914.     if not(stick) then
  5915.        
  5916.         local planks, mess = T:GetItemFromChest("wood", "planks", 2, 4)
  5917.        
  5918.         if not(planks) then
  5919.            
  5920.             local logs, mess = T:GetItemFromChest("wood", "log", 1, 4)
  5921.            
  5922.             while not(logs) do
  5923.                
  5924.                 HarvestTreeFarm()
  5925.                 logs, mess = T:GetItemFromChest("wood", "log", 1, 4)
  5926.                
  5927.             end
  5928.            
  5929.             T:Craft("planks", 2, "log")
  5930.            
  5931.         end
  5932.        
  5933.         T:Craft("stick", 1, "planks")
  5934.         craft = true
  5935.        
  5936.         GetChest()
  5937.         SortStorage()
  5938.         stick, mess = T:GetItemFromChest("wood", "stick", 1, 9)
  5939.     end
  5940.    
  5941.     local diamond, mess = T:GetItemFromChest("diamond", "diamond", 2, 5)
  5942.    
  5943.     if not(diamond) then
  5944.        
  5945.         SaveFile("log", mess, true)
  5946.         error()
  5947.        
  5948.     end
  5949.    
  5950.     local count, slots1 = T:LookInvItems("stick", true)
  5951.     local count, slots2 = T:LookInvItems("diamond", true)
  5952.    
  5953.     if slots1[1] ~= 9 then
  5954.        
  5955.         T.select(slots1[1])
  5956.         T.transferTo(9, 1)
  5957.        
  5958.     end
  5959.    
  5960.     if slots2[1] ~= 5 then
  5961.        
  5962.         T.select(slots2[1])
  5963.         T.transferTo(5, 2)
  5964.         count, slots2 = T:LookInvItems("diamond", true)
  5965.        
  5966.     end
  5967.    
  5968.     T.select(slots2[1])
  5969.     T.transferTo(1, 1)
  5970.    
  5971.     if not(craft) then
  5972.        
  5973.         GetChest()
  5974.         T.place()
  5975.        
  5976.         for i = 2, 4 do
  5977.             T.select(i)
  5978.             T.drop()
  5979.         end
  5980.        
  5981.         for i = 6, 8 do
  5982.             T.select(i)
  5983.             T.drop()
  5984.         end
  5985.        
  5986.         for i = 10, 16 do
  5987.             T.select(i)
  5988.             T.drop()
  5989.         end
  5990.        
  5991.     end
  5992.    
  5993.     T.select(4)
  5994.     T.craft()
  5995.    
  5996.     if not(craft) then
  5997.        
  5998.         while T.suck() do end
  5999.        
  6000.         T.select(chestSlot)
  6001.         T.dig()
  6002.        
  6003.     end
  6004.    
  6005.     GetChest()
  6006.     GetModem()
  6007.     SortStorage()
  6008.    
  6009.     if N == nil or N == 1 then
  6010.        
  6011.         Status = 15
  6012.        
  6013.         SaveFile("status")
  6014.        
  6015.     end
  6016.    
  6017. end
  6018.  
  6019. function MakePickAxe()
  6020.    
  6021.     SaveFile("log", "Making pickaxe", true)
  6022.    
  6023.     local stick, mess = T:GetItemFromChest("wood", "stick", 2, 10)
  6024.     local craft = false
  6025.    
  6026.     if not(stick) then
  6027.        
  6028.         local planks, mess = T:GetItemFromChest("wood", "planks", 2, 4)
  6029.        
  6030.         if not(planks) then
  6031.            
  6032.             local logs, mess = T:GetItemFromChest("wood", "log", 1, 4)
  6033.            
  6034.             while not(logs) do
  6035.                
  6036.                 HarvestTreeFarm()
  6037.                 logs, mess = T:GetItemFromChest("wood", "log", 1, 4)
  6038.                
  6039.             end
  6040.            
  6041.             T:Craft("planks", 2, "log")
  6042.            
  6043.         end
  6044.        
  6045.         T:Craft("stick", 2, "planks")
  6046.         craft = true
  6047.        
  6048.         GetChest()
  6049.         SortStorage()
  6050.         stick, mess = T:GetItemFromChest("wood", "stick", 2, 9)
  6051.     end
  6052.    
  6053.     local diamond, mess = T:GetItemFromChest("diamond", "diamond", 3, 2)
  6054.    
  6055.     if not(diamond) then
  6056.        
  6057.         SaveFile("log", mess, true)
  6058.         error()
  6059.        
  6060.     end
  6061.    
  6062.     local count, slots1 = T:LookInvItems("stick", true)
  6063.     local count, slots2 = T:LookInvItems("diamond", true)
  6064.    
  6065.     if slots1[1] ~= 10 then
  6066.        
  6067.         T.select(slots1[1])
  6068.         T.transferTo(10, 2)
  6069.         count, slots1 = T:LookInvItems("stick", true)
  6070.        
  6071.     end
  6072.    
  6073.     T.select(slots1[1])
  6074.     T.transferTo(6, 1)
  6075.    
  6076.     if slots2[1] ~= 2 then
  6077.        
  6078.         T.select(slots2[1])
  6079.         T.transferTo(2, 3)
  6080.         count, slots2 = T:LookInvItems("diamond", true)
  6081.        
  6082.     end
  6083.    
  6084.     T.select(slots2[1])
  6085.     T.transferTo(1, 1)
  6086.     T.transferTo(3, 1)
  6087.    
  6088.     if not(craft) then
  6089.        
  6090.         GetChest()
  6091.         T.place()
  6092.        
  6093.         for i = 4, 5 do
  6094.             T.select(i)
  6095.             T.drop()
  6096.         end
  6097.        
  6098.         for i = 7, 9 do
  6099.             T.select(i)
  6100.             T.drop()
  6101.         end
  6102.        
  6103.         for i = 11, 16 do
  6104.             T.select(i)
  6105.             T.drop()
  6106.         end
  6107.        
  6108.     end
  6109.    
  6110.     T.select(4)
  6111.     T.craft()
  6112.    
  6113.     if not(craft) then
  6114.        
  6115.         while T.suck() do end
  6116.        
  6117.         T.select(chestSlot)
  6118.         T.dig()
  6119.        
  6120.     end
  6121.    
  6122.     GetChest()
  6123.     GetModem()
  6124.     SortStorage()
  6125.    
  6126. end
  6127.  
  6128. function AttackMobs(N)
  6129.    
  6130.     GetChest()
  6131.     GetModem()
  6132.    
  6133.     SaveFile("log", "Attacking Mobs for loot", true)
  6134.    
  6135.     local Stone, mess = T:GetItemFromChest("stone", "cobblestone", 40, 2)
  6136.    
  6137.     turtle.select(chestSlot)
  6138.     turtle.digUp()
  6139.    
  6140.     if not(Stone) then
  6141.        
  6142.         Generate(40, 2)
  6143.        
  6144.     end
  6145.    
  6146.     local sword, mess = T:GetItemFromChest("diamond", "diamond_sword", 1, 1)
  6147.    
  6148.     if not(sword) then
  6149.        
  6150.         MakeSword(2)
  6151.         sword, mess = T:GetItemFromChest("diamond", "diamond_sword", 1, 1)
  6152.        
  6153.     end
  6154.    
  6155.     T.select(1)
  6156.     T.equipLeft()
  6157.    
  6158.     T:GoTo(Mine.x, Mine.y, Mine.z)
  6159.    
  6160.     for I = 1, 2 do
  6161.         T:TurnLeft()
  6162.     end
  6163.    
  6164.     turtle.select(2)
  6165.    
  6166.     while not(T.detectDown()) do
  6167.         if T:getY() == 22 then
  6168.             T.placeUp()
  6169.         end
  6170.         T:Down()
  6171.     end
  6172.    
  6173.     while not(T.detect()) do
  6174.         while T.attack() do end
  6175.         T.placeDown()
  6176.         T:Forward()
  6177.     end
  6178.    
  6179.     for i = 1, 2 do
  6180.         T:TurnLeft()
  6181.     end
  6182.    
  6183.     T:GoTo(Mine.x, T:getY(), Mine.z)
  6184.    
  6185.     while T.attack() do end
  6186.    
  6187.     for i = 1, 2 do
  6188.         T:TurnLeft()
  6189.     end
  6190.    
  6191.     T:Forward()
  6192.    
  6193.     if N == nil or N == 1 or N == 3 then
  6194.        
  6195.         local bone = false
  6196.        
  6197.         while not(bone) do
  6198.            
  6199.             while T.attack() do end
  6200.            
  6201.             for i = 1, 16 do
  6202.                 local details = T.getItemDetail(i)
  6203.                
  6204.                 if details and string.find(details.name, "bone") and details.count > 5 then
  6205.                     bone = true
  6206.                 end
  6207.             end
  6208.            
  6209.         end
  6210.        
  6211.     elseif N == 2 then
  6212.        
  6213.         local bone = false
  6214.        
  6215.         while not(bone) do
  6216.            
  6217.             while T.attack() do end
  6218.            
  6219.             for i = 1, 16 do
  6220.                 local details = T.getItemDetail(i)
  6221.                
  6222.                 if details and string.find(details.name, "ender_pearl") and details.count > 5 then
  6223.                     bone = true
  6224.                 end
  6225.             end
  6226.            
  6227.         end
  6228.        
  6229.     end
  6230.    
  6231.     T:GoTo(Mine.x, T:getY(), Mine.z)
  6232.    
  6233.     while not(T.detectUp()) do
  6234.         T:Up()
  6235.     end
  6236.    
  6237.     T.select(1)
  6238.     T.equipLeft()
  6239.    
  6240.     T.digUp()
  6241.    
  6242.     T:GoTo(Mine.x, Mine.y, Mine.z)
  6243.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  6244.     T:TurnDirection(T:getHomeR())
  6245.    
  6246.     SortStorage()
  6247.    
  6248.     T:Refuel()
  6249.     GetModem()
  6250.    
  6251.     if N == nil or N == 1 then
  6252.        
  6253.         Status = 16
  6254.        
  6255.         SaveFile("status")
  6256.        
  6257.     end
  6258.    
  6259. end
  6260.  
  6261. function MinetoBedRock()
  6262.    
  6263.     SaveFile("log", "Mine to BedRock", true)
  6264.    
  6265.     GetModem()
  6266.    
  6267.     local torches, mess = T:GetItemFromChest("wood", "torch", 64, 1)
  6268.    
  6269.     while not(torches) do
  6270.        
  6271.         if mess == "Cant find torch" then
  6272.            
  6273.             local Torchnumber, Torchslots = T:LookInvItems("torch", true)
  6274.            
  6275.             local count = math.ceil((64 - Torchnumber) / 4)
  6276.            
  6277.             for _ = 1, count do
  6278.                
  6279.                 MakeTorches()
  6280.                 T:Refuel()
  6281.             end
  6282.            
  6283.             SortStorage()
  6284.             GetModem()
  6285.             torches, mess = T:GetItemFromChest("wood", "torch", 64, 4)
  6286.            
  6287.         elseif mess ~= nil then
  6288.            
  6289.             if mess == "Cant find chest for torch" then
  6290.                
  6291.                 SaveFile("log", mess, true)
  6292.                 error()
  6293.                
  6294.             end
  6295.            
  6296.         end
  6297.        
  6298.     end
  6299.    
  6300.     local Stone, mess = T:GetItemFromChest("stone", "cobblestone", 32, 2)
  6301.    
  6302.     if not(Stone) then
  6303.        
  6304.         Generate(32, 2)
  6305.        
  6306.     end
  6307.    
  6308.     local Torchnumber, Torchslots = T:LookInvItems("torch", true)
  6309.     local Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  6310.    
  6311.     T:GoTo(Mine.x, Mine.y, Mine.z)
  6312.    
  6313.     for I = 1, 2 do
  6314.         T:TurnLeft()
  6315.     end
  6316.    
  6317.     while T:getY() > 7 do
  6318.         T:Down()
  6319.     end
  6320.    
  6321.     local SY = T:getY()
  6322.    
  6323.     for i = 1, 36 do
  6324.         T:Forward()
  6325.     end
  6326.    
  6327.     T:TurnLeft()
  6328.    
  6329.     for i = 1, 18 do
  6330.         T:Forward()
  6331.     end
  6332.    
  6333.     for I = 1, 2 do
  6334.         T:TurnLeft()
  6335.     end
  6336.    
  6337.     T.select(1)
  6338.    
  6339.     local Succes, Detail = T.inspectDown()
  6340.     local a = 0
  6341.    
  6342.     while not(Succes) do
  6343.        
  6344.         T:Down()
  6345.        
  6346.         if T:getY() < 7 then
  6347.            
  6348.             a = T:Add(a, 1)
  6349.             checkForOre()
  6350.             T.select(Stoneslots[1])
  6351.            
  6352.             T:SortInvItems(2)
  6353.             Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  6354.            
  6355.             local stonecount = T.getItemCount(Stoneslots[1])
  6356.            
  6357.             if stonecount < 10 then
  6358.                
  6359.                 local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  6360.                
  6361.                 T:GoTo(ssx, SY+1, ssz)
  6362.                 T:GoTo(Mine.x, SY+1, Mine.z)
  6363.                 T:GoTo(Mine.x, SY+1, Mine.z)
  6364.                 T:GoTo(Mine.x, SY+1, Mine.z)
  6365.                 T:GoTo(Mine.x, SY+1, Mine.z)
  6366.                 T:GoTo(Mine.x, Mine.y, Mine.z)
  6367.                
  6368.                 T:Refuel()
  6369.                 GetChest()
  6370.                 GetModem()
  6371.                
  6372.                 Stone, mess = T:GetItemFromChest("stone", "cobblestone", 32, 2)
  6373.                
  6374.                 if not(Stone) then
  6375.                    
  6376.                     Generate(32, 2)
  6377.                    
  6378.                 end
  6379.                
  6380.                 T:GoTo(Mine.x, Mine.y, Mine.z)
  6381.                 T:GoTo(Mine.x, SY+1, Mine.z)
  6382.                 T:GoTo(ssx, SY+1, ssz)
  6383.                
  6384.                 T:TurnLeft()
  6385.                
  6386.                 local succes1 = T.detect()
  6387.                
  6388.                 for _ = 1, 2 do T:TurnRight() end
  6389.                
  6390.                 local succes2 = T.detect()
  6391.                
  6392.                 T:TurnLeft()
  6393.                
  6394.                 if succes1 or succes2 then
  6395.                     local sxx, szz = T:getx(), T:getZ()
  6396.                     T:Forward()
  6397.                    
  6398.                     if T:getX() == sxx then
  6399.                         T:GoTo(sxx, SY+1, ssz)
  6400.                     elseif T:getz() == szz then
  6401.                         T:GoTo(ssx, SY+1, szz)
  6402.                     end
  6403.                    
  6404.                 end
  6405.                
  6406.                 T:GoTo(ssx, SY+1, ssz)
  6407.                 T:GoTo(ssx, SY+1, ssz)
  6408.                 T:GoTo(ssx, SY, ssz)
  6409.                 T:GoTo(ssx, ssy, ssz)
  6410.                 T:TurnDirection(ssr)
  6411.                
  6412.             end
  6413.            
  6414.             for b = 1, 4 do
  6415.                 T:TurnLeft()
  6416.                 T.place()
  6417.             end
  6418.             T.select(1)
  6419.            
  6420.         end
  6421.        
  6422.         Succes, Detail = T.inspectDown()
  6423.        
  6424.        
  6425.     end
  6426.    
  6427.     while Succes and Detail.name ~= "minecraft:bedrock" do
  6428.        
  6429.         T.digDown()
  6430.         T:Down()
  6431.         a = T:Add(a, 1)
  6432.         checkForOre()
  6433.         T.select(Stoneslots[1])
  6434.        
  6435.         T:SortInvItems(2)
  6436.         Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  6437.        
  6438.         local stonecount = T.getItemCount(Stoneslots[1])
  6439.        
  6440.         if stonecount < 10 then
  6441.            
  6442.             local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  6443.            
  6444.             T:GoTo(ssx, SY+1, ssz)
  6445.             T:GoTo(Mine.x, SY+1, Mine.z)
  6446.             T:GoTo(Mine.x, SY+1, Mine.z)
  6447.             T:GoTo(Mine.x, SY+1, Mine.z)
  6448.             T:GoTo(Mine.x, SY+1, Mine.z)
  6449.             T:GoTo(Mine.x, Mine.y, Mine.z)
  6450.            
  6451.             T:Refuel()
  6452.             GetChest()
  6453.             GetModem()
  6454.            
  6455.             Stone, mess = T:GetItemFromChest("stone", "cobblestone", 32, 2)
  6456.            
  6457.             if not(Stone) then
  6458.                
  6459.                 Generate(32, 2)
  6460.                
  6461.             end
  6462.            
  6463.             T:GoTo(Mine.x, Mine.y, Mine.z)
  6464.             T:GoTo(Mine.x, SY+1, Mine.z)
  6465.             T:GoTo(ssx, SY+1, ssz)
  6466.            
  6467.             T:TurnLeft()
  6468.            
  6469.             local succes1 = T.detect()
  6470.            
  6471.             for _ = 1, 2 do T:TurnRight() end
  6472.            
  6473.             local succes2 = T.detect()
  6474.            
  6475.             T:TurnLeft()
  6476.            
  6477.             if succes1 or succes2 then
  6478.                 local sxx, szz = T:getx(), T:getZ()
  6479.                 T:Forward()
  6480.                
  6481.                 if T:getX() == sxx then
  6482.                     T:GoTo(sxx, SY+1, ssz)
  6483.                 elseif T:getz() == szz then
  6484.                     T:GoTo(ssx, SY+1, szz)
  6485.                 end
  6486.                
  6487.             end
  6488.            
  6489.             T:GoTo(ssx, SY+1, ssz)
  6490.             T:GoTo(ssx, SY+1, ssz)
  6491.             T:GoTo(ssx, SY, ssz)
  6492.             T:GoTo(ssx, ssy, ssz)
  6493.             T:TurnDirection(ssr)
  6494.            
  6495.         end
  6496.        
  6497.         for b = 1, 4 do
  6498.             T:TurnLeft()
  6499.             T.place()
  6500.         end
  6501.         T.select(1)
  6502.         Succes, Detail = T.inspectDown()
  6503.        
  6504.    
  6505.     end
  6506.    
  6507.     for b = 1, a do
  6508.        
  6509.         T.select(Stoneslots[1])
  6510.         T:Up()
  6511.         T.placeDown()
  6512.        
  6513.     end
  6514.    
  6515.     T:SortInvItems(2)
  6516.    
  6517.     Torchnumber, Torchslots = T:LookInvItems("torch", true)
  6518.     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  6519.    
  6520.     for i = 1, 34 do
  6521.        
  6522.         for I = 1, 36 do
  6523.            
  6524.             if (I%7) == 1 and (i%7) == 1 then
  6525.                
  6526.                 Torchnumber, Torchslots = T:LookInvItems("torch", true)
  6527.                
  6528.                 local torchcount = T.getItemCount(Torchslots[1])
  6529.                
  6530.                 if torchcount == 0 then
  6531.                    
  6532.                     local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  6533.                    
  6534.                     T:GoTo(ssx, SY+1, ssz)
  6535.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6536.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6537.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6538.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6539.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  6540.                    
  6541.                     T:Refuel()
  6542.                     GetChest()
  6543.                     GetModem()
  6544.                    
  6545.                     torches, mess = T:GetItemFromChest("wood", "torch", 64, 4)
  6546.                    
  6547.                     while not(torches) do
  6548.                        
  6549.                         if mess == "Cant find torch" then
  6550.                            
  6551.                             local Torchnumber, Torchslots = T:LookInvItems("torch", true)
  6552.                            
  6553.                             local count = math.ceil((64 - Torchnumber) / 4)
  6554.                            
  6555.                             for _ = 1, count do
  6556.                                
  6557.                                 MakeTorches()
  6558.                                 T:Refuel()
  6559.                             end
  6560.                            
  6561.                             SortStorage()
  6562.                             GetModem()
  6563.                             torches, mess = T:GetItemFromChest("wood", "torch", 64, 4)
  6564.                            
  6565.                         elseif mess ~= nil then
  6566.                            
  6567.                             if mess == "Cant find chest for torch" then
  6568.                                
  6569.                                 SaveFile("log", mess, true)
  6570.                                 error()
  6571.                                
  6572.                             end
  6573.                            
  6574.                         end
  6575.                        
  6576.                     end
  6577.                    
  6578.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  6579.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6580.                     T:GoTo(ssx, SY+1, ssz)
  6581.                
  6582.                     T:TurnLeft()
  6583.                    
  6584.                     local succes1 = T.detect()
  6585.                    
  6586.                     for _ = 1, 2 do T:TurnRight() end
  6587.                    
  6588.                     local succes2 = T.detect()
  6589.                    
  6590.                     T:TurnLeft()
  6591.                    
  6592.                     if succes1 or succes2 then
  6593.                         local sxx, szz = T:getx(), T:getZ()
  6594.                         T:Forward()
  6595.                        
  6596.                         if T:getX() == sxx then
  6597.                             T:GoTo(sxx, SY+1, ssz)
  6598.                         elseif T:getz() == szz then
  6599.                             T:GoTo(ssx, SY+1, szz)
  6600.                         end
  6601.                        
  6602.                     end
  6603.                    
  6604.                     T:GoTo(ssx, SY+1, ssz)
  6605.                     T:GoTo(ssx, SY+1, ssz)
  6606.                     T:GoTo(ssx, SY, ssz)
  6607.                     T:GoTo(ssx, ssy, ssz)
  6608.                     T:TurnDirection(ssr)
  6609.                    
  6610.                 end
  6611.                
  6612.                 T.select(Torchslots[1])
  6613.                 T:Up()
  6614.                 T.placeDown()
  6615.                
  6616.             end
  6617.            
  6618.             T.select(1)
  6619.            
  6620.             while T.dig() do end
  6621.            
  6622.             T:Forward()
  6623.            
  6624.             while T:getY() > SY do
  6625.                
  6626.                 T.digDown()
  6627.                 T:Down()
  6628.                
  6629.             end
  6630.            
  6631.             while T:getY() < SY do
  6632.                
  6633.                 while T.digUp() do end
  6634.                 T:Up()
  6635.                
  6636.             end
  6637.            
  6638.             while T.digUp() do end
  6639.            
  6640.             Succes, Detail = T.inspectDown()
  6641.             a = 0
  6642.            
  6643.             while not(Succes) do
  6644.                
  6645.                 T:Down()
  6646.                
  6647.                 if T:getY() < 7 then
  6648.                    
  6649.                     a = T:Add(a, 1)
  6650.                     checkForOre()
  6651.                     T.select(Stoneslots[1])
  6652.                    
  6653.                     T:SortInvItems(2)
  6654.                     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  6655.                    
  6656.                     local stonecount = T.getItemCount(Stoneslots[1])
  6657.                    
  6658.                     if stonecount < 10 then
  6659.                        
  6660.                         local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  6661.                        
  6662.                         T:GoTo(ssx, SY+1, ssz)
  6663.                         T:GoTo(Mine.x, SY+1, Mine.z)
  6664.                         T:GoTo(Mine.x, SY+1, Mine.z)
  6665.                         T:GoTo(Mine.x, SY+1, Mine.z)
  6666.                         T:GoTo(Mine.x, SY+1, Mine.z)
  6667.                         T:GoTo(Mine.x, Mine.y, Mine.z)
  6668.                        
  6669.                         T:Refuel()
  6670.                         GetChest()
  6671.                         GetModem()
  6672.                        
  6673.                         Stone, mess = T:GetItemFromChest("stone", "cobblestone", 32, 2)
  6674.                        
  6675.                         if not(Stone) then
  6676.                            
  6677.                             Generate(32, 2)
  6678.                            
  6679.                         end
  6680.                        
  6681.                         T:GoTo(Mine.x, Mine.y, Mine.z)
  6682.                         T:GoTo(Mine.x, SY+1, Mine.z)
  6683.                         T:GoTo(ssx, SY+1, ssz)
  6684.                        
  6685.                         T:TurnLeft()
  6686.                        
  6687.                         local succes1 = T.detect()
  6688.                        
  6689.                         for _ = 1, 2 do T:TurnRight() end
  6690.                        
  6691.                         local succes2 = T.detect()
  6692.                        
  6693.                         T:TurnLeft()
  6694.                        
  6695.                         if succes1 or succes2 then
  6696.                             local sxx, szz = T:getx(), T:getZ()
  6697.                             T:Forward()
  6698.                            
  6699.                             if T:getX() == sxx then
  6700.                                 T:GoTo(sxx, SY+1, ssz)
  6701.                             elseif T:getz() == szz then
  6702.                                 T:GoTo(ssx, SY+1, szz)
  6703.                             end
  6704.                            
  6705.                         end
  6706.                        
  6707.                         T:GoTo(ssx, SY+1, ssz)
  6708.                         T:GoTo(ssx, SY+1, ssz)
  6709.                         T:GoTo(ssx, SY, ssz)
  6710.                         T:GoTo(ssx, ssy, ssz)
  6711.                         T:TurnDirection(ssr)
  6712.                        
  6713.                     end
  6714.                    
  6715.                     for b = 1, 4 do
  6716.                         T:TurnLeft()
  6717.                         T.place()
  6718.                     end
  6719.                     T.select(1)
  6720.                    
  6721.                 end
  6722.                
  6723.                 Succes, Detail = T.inspectDown()
  6724.                
  6725.             end
  6726.            
  6727.             while Succes and Detail.name ~= "minecraft:bedrock" do
  6728.                
  6729.                 T.digDown()
  6730.                 T:Down()
  6731.                 a = T:Add(a, 1)
  6732.                 checkForOre()
  6733.                 T.select(Stoneslots[1])
  6734.                
  6735.                 T:SortInvItems(2)
  6736.                 Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  6737.                
  6738.                 local stonecount = T.getItemCount(Stoneslots[1])
  6739.                
  6740.                 if stonecount < 10 then
  6741.                    
  6742.                     local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  6743.                    
  6744.                     T:GoTo(ssx, SY+1, ssz)
  6745.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6746.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6747.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6748.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6749.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  6750.                    
  6751.                     T:Refuel()
  6752.                     GetChest()
  6753.                     GetModem()
  6754.                    
  6755.                     Stone, mess = T:GetItemFromChest("stone", "cobblestone", 32, 2)
  6756.                    
  6757.                     if not(Stone) then
  6758.                        
  6759.                         Generate(32, 2)
  6760.                        
  6761.                     end
  6762.                    
  6763.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  6764.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6765.                     T:GoTo(ssx, SY+1, ssz)
  6766.                    
  6767.                     T:TurnLeft()
  6768.                    
  6769.                     local succes1 = T.detect()
  6770.                    
  6771.                     for _ = 1, 2 do T:TurnRight() end
  6772.                    
  6773.                     local succes2 = T.detect()
  6774.                    
  6775.                     T:TurnLeft()
  6776.                    
  6777.                     if succes1 or succes2 then
  6778.                         local sxx, szz = T:getX(), T:getZ()
  6779.                         T:Forward()
  6780.                        
  6781.                         if T:getX() == sxx then
  6782.                             T:GoTo(sxx, SY+1, ssz)
  6783.                         elseif T:getZ() == szz then
  6784.                             T:GoTo(ssx, SY+1, szz)
  6785.                         end
  6786.                        
  6787.                     end
  6788.                    
  6789.                     T:GoTo(ssx, SY+1, ssz)
  6790.                     T:GoTo(ssx, SY+1, ssz)
  6791.                     T:GoTo(ssx, SY, ssz)
  6792.                     T:GoTo(ssx, ssy, ssz)
  6793.                     T:TurnDirection(ssr)
  6794.                    
  6795.                 end
  6796.                
  6797.                 for b = 1, 4 do
  6798.                     T:TurnLeft()
  6799.                     T.place()
  6800.                 end
  6801.                 T.select(1)
  6802.                 Succes, Detail = T.inspectDown()
  6803.                
  6804.             end
  6805.            
  6806.             for b = 1, a do
  6807.                
  6808.                 T.select(Stoneslots[1])
  6809.                 T:Up()
  6810.                 T.placeDown()
  6811.                
  6812.             end
  6813.            
  6814.         end
  6815.        
  6816.         T:SortInvItems(2)
  6817.        
  6818.         Torchnumber, Torchslots = T:LookInvItems("torch", true)
  6819.         Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  6820.        
  6821.         if (i%2) == 1 and i < 34 then
  6822.            
  6823.             if (i%7) == 1 then
  6824.                
  6825.                 Torchnumber, Torchslots = T:LookInvItems("torch", true)
  6826.                
  6827.                 local torchcount = T.getItemCount(Torchslots[1])
  6828.                
  6829.                 if torchcount == 0 then
  6830.                    
  6831.                     local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  6832.                    
  6833.                     T:GoTo(ssx, SY+1, ssz)
  6834.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6835.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6836.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6837.                     T:GoTo(Mine.x, SY+1, Mine.z)
  6838.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  6839.                    
  6840.                     T:Refuel()
  6841.                     GetChest()
  6842.                     GetModem()
  6843.                    
  6844.                     torches, mess = T:GetItemFromChest("wood", "torch", 64, 4)
  6845.                    
  6846.                     while not(torches) do
  6847.                        
  6848.                         if mess == "Cant find torch" then
  6849.                            
  6850.                             local Torchnumber, Torchslots = T:LookInvItems("torch", true)
  6851.                            
  6852.                             local count = math.ceil((64 - Torchnumber) / 4)
  6853.                            
  6854.                             for _ = 1, count do
  6855.                                
  6856.                                 MakeTorches()
  6857.                                 T:Refuel()
  6858.                             end
  6859.                            
  6860.                             SortStorage()
  6861.                             GetModem()
  6862.                             torches, mess = T:GetItemFromChest("wood", "torch", 64, 4)
  6863.                            
  6864.                         elseif mess ~= nil then
  6865.                            
  6866.                             if mess == "Cant find chest for torch" then
  6867.                                
  6868.                                 SaveFile("log", mess, true)
  6869.                                 error()
  6870.                                
  6871.                             end
  6872.                            
  6873.                         end
  6874.                        
  6875.                     end
  6876.                    
  6877.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  6878.                     T:GoTo(Mine.x, SY, Mine.z)
  6879.                     T:GoTo(ssx, SY+1, ssz)
  6880.                    
  6881.                     T:TurnLeft()
  6882.                    
  6883.                     local succes1 = T.detect()
  6884.                    
  6885.                     for _ = 1, 2 do T:TurnRight() end
  6886.                    
  6887.                     local succes2 = T.detect()
  6888.                    
  6889.                     T:TurnLeft()
  6890.                    
  6891.                     if succes1 or succes2 then
  6892.                         local sxx, szz = T:getx(), T:getZ()
  6893.                         T:Forward()
  6894.                        
  6895.                         if T:getX() == sxx then
  6896.                             T:GoTo(sxx, SY+1, ssz)
  6897.                         elseif T:getz() == szz then
  6898.                             T:GoTo(ssx, SY+1, szz)
  6899.                         end
  6900.                        
  6901.                     end
  6902.                    
  6903.                     T:GoTo(ssx, SY+1, ssz)
  6904.                     T:GoTo(ssx, SY+1, ssz)
  6905.                     T:GoTo(ssx, SY, ssz)
  6906.                     T:GoTo(ssx, ssy, ssz)
  6907.                     T:TurnDirection(ssr)
  6908.                    
  6909.                 end
  6910.                
  6911.                 T.select(Torchslots[1])
  6912.                 T:Up()
  6913.                 T.placeDown()
  6914.                
  6915.             end
  6916.            
  6917.             T:TurnRight()
  6918.            
  6919.             T.select(1)
  6920.            
  6921.             while T.dig() do end
  6922.            
  6923.             T:Forward()
  6924.            
  6925.             while T:getY() > SY do
  6926.                
  6927.                 T.digDown()
  6928.                 T:Down()
  6929.                
  6930.             end
  6931.            
  6932.             while T:getY() < SY do
  6933.                
  6934.                 while T.digUp() do end
  6935.                 T:Up()
  6936.                
  6937.             end
  6938.            
  6939.             while T.digUp() do end
  6940.            
  6941.             Succes, Detail = T.inspectDown()
  6942.             a = 0
  6943.            
  6944.             while not(Succes) do
  6945.                
  6946.                 T:Down()
  6947.                
  6948.                 if T:getY() < 7 then
  6949.                    
  6950.                     a = T:Add(a, 1)
  6951.                     checkForOre()
  6952.                     T.select(Stoneslots[1])
  6953.                    
  6954.                     T:SortInvItems(2)
  6955.                     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  6956.                    
  6957.                     local stonecount = T.getItemCount(Stoneslots[1])
  6958.                    
  6959.                     if stonecount < 10 then
  6960.                        
  6961.                         local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  6962.                        
  6963.                         T:GoTo(ssx, SY+1, ssz)
  6964.                         T:GoTo(Mine.x, SY+1, Mine.z)
  6965.                         T:GoTo(Mine.x, SY+1, Mine.z)
  6966.                         T:GoTo(Mine.x, SY+1, Mine.z)
  6967.                         T:GoTo(Mine.x, SY+1, Mine.z)
  6968.                         T:GoTo(Mine.x, Mine.y, Mine.z)
  6969.                        
  6970.                         T:Refuel()
  6971.                         GetChest()
  6972.                         GetModem()
  6973.                        
  6974.                         Stone, mess = T:GetItemFromChest("stone", "cobblestone", 32, 2)
  6975.                        
  6976.                         if not(Stone) then
  6977.                            
  6978.                             Generate(32, 2)
  6979.                            
  6980.                         end
  6981.                        
  6982.                         T:GoTo(Mine.x, Mine.y, Mine.z)
  6983.                         T:GoTo(Mine.x, SY+1, Mine.z)
  6984.                         T:GoTo(ssx, SY+1, ssz)
  6985.                        
  6986.                         T:TurnLeft()
  6987.                        
  6988.                         local succes1 = T.detect()
  6989.                        
  6990.                         for _ = 1, 2 do T:TurnRight() end
  6991.                        
  6992.                         local succes2 = T.detect()
  6993.                        
  6994.                         T:TurnLeft()
  6995.                        
  6996.                         if succes1 or succes2 then
  6997.                             local sxx, szz = T:getx(), T:getZ()
  6998.                             T:Forward()
  6999.                            
  7000.                             if T:getX() == sxx then
  7001.                                 T:GoTo(sxx, SY+1, ssz)
  7002.                             elseif T:getz() == szz then
  7003.                                 T:GoTo(ssx, SY+1, szz)
  7004.                             end
  7005.                            
  7006.                         end
  7007.                        
  7008.                         T:GoTo(ssx, SY+1, ssz)
  7009.                         T:GoTo(ssx, SY+1, ssz)
  7010.                         T:GoTo(ssx, SY, ssz)
  7011.                         T:GoTo(ssx, ssy, ssz)
  7012.                         T:TurnDirection(ssr)
  7013.                        
  7014.                     end
  7015.                    
  7016.                     for b = 1, 4 do
  7017.                         T:TurnLeft()
  7018.                         T.place()
  7019.                     end
  7020.                     T.select(1)
  7021.                    
  7022.                 end
  7023.                
  7024.                 Succes, Detail = T.inspectDown()
  7025.                
  7026.             end
  7027.            
  7028.             while Succes and Detail.name ~= "minecraft:bedrock" do
  7029.                
  7030.                 T.digDown()
  7031.                 T:Down()
  7032.                 a = T:Add(a, 1)
  7033.                 checkForOre()
  7034.                 T.select(Stoneslots[1])
  7035.                
  7036.                 T:SortInvItems(2)
  7037.                 Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  7038.                
  7039.                 local stonecount = T.getItemCount(Stoneslots[1])
  7040.                
  7041.                 if stonecount < 10 then
  7042.                    
  7043.                     local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  7044.                    
  7045.                     T:GoTo(ssx, SY+1, ssz)
  7046.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7047.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7048.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7049.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7050.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  7051.                    
  7052.                     T:Refuel()
  7053.                     GetChest()
  7054.                     GetModem()
  7055.                    
  7056.                     Stone, mess = T:GetItemFromChest("stone", "cobblestone", 32, 2)
  7057.                    
  7058.                     if not(Stone) then
  7059.                        
  7060.                         Generate(32, 2)
  7061.                        
  7062.                     end
  7063.                    
  7064.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  7065.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7066.                     T:GoTo(ssx, SY+1, ssz)
  7067.                    
  7068.                     T:TurnLeft()
  7069.                    
  7070.                     local succes1 = T.detect()
  7071.                    
  7072.                     for _ = 1, 2 do T:TurnRight() end
  7073.                    
  7074.                     local succes2 = T.detect()
  7075.                    
  7076.                     T:TurnLeft()
  7077.                    
  7078.                     if succes1 or succes2 then
  7079.                         local sxx, szz = T:getx(), T:getZ()
  7080.                         T:Forward()
  7081.                        
  7082.                         if T:getX() == sxx then
  7083.                             T:GoTo(sxx, SY+1, ssz)
  7084.                         elseif T:getz() == szz then
  7085.                             T:GoTo(ssx, SY+1, szz)
  7086.                         end
  7087.                        
  7088.                     end
  7089.                    
  7090.                     T:GoTo(ssx, SY+1, ssz)
  7091.                     T:GoTo(ssx, SY+1, ssz)
  7092.                     T:GoTo(ssx, SY, ssz)
  7093.                     T:GoTo(ssx, ssy, ssz)
  7094.                     T:TurnDirection(ssr)
  7095.                    
  7096.                 end
  7097.                
  7098.                 for b = 1, 4 do
  7099.                     T:TurnLeft()
  7100.                     T.place()
  7101.                 end
  7102.                 T.select(1)
  7103.                 Succes, Detail = T.inspectDown()
  7104.                
  7105.             end
  7106.            
  7107.             for b = 1, a do
  7108.                
  7109.                 T.select(Stoneslots[1])
  7110.                 T:Up()
  7111.                 T.placeDown()
  7112.                
  7113.             end
  7114.            
  7115.             T:TurnRight()
  7116.            
  7117.         elseif i < 34 then
  7118.            
  7119.             if (i%7) == 1 then
  7120.                
  7121.                 Torchnumber, Torchslots = T:LookInvItems("torch", true)
  7122.                
  7123.                 local torchcount = T.getItemCount(Torchslots[1])
  7124.                
  7125.                 if torchcount == 0 then
  7126.                    
  7127.                     local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  7128.                    
  7129.                     T:GoTo(ssx, SY+1, ssz)
  7130.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7131.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7132.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7133.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7134.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  7135.                    
  7136.                     T:Refuel()
  7137.                     GetChest()
  7138.                     GetModem()
  7139.                    
  7140.                     torches, mess = T:GetItemFromChest("wood", "torch", 64, 4)
  7141.                    
  7142.                     while not(torches) do
  7143.                        
  7144.                         if mess == "Cant find torch" then
  7145.                            
  7146.                             local Torchnumber, Torchslots = T:LookInvItems("torch", true)
  7147.                            
  7148.                             local count = math.ceil((64 - Torchnumber) / 4)
  7149.                            
  7150.                             for _ = 1, count do
  7151.                                
  7152.                                 MakeTorches()
  7153.                                 T:Refuel()
  7154.                             end
  7155.                            
  7156.                             SortStorage()
  7157.                             GetModem()
  7158.                             torches, mess = T:GetItemFromChest("wood", "torch", 64, 4)
  7159.                            
  7160.                         elseif mess ~= nil then
  7161.                            
  7162.                             if mess == "Cant find chest for torch" then
  7163.                                
  7164.                                 SaveFile("log", mess, true)
  7165.                                 error()
  7166.                                
  7167.                             end
  7168.                            
  7169.                         end
  7170.                        
  7171.                     end
  7172.                    
  7173.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  7174.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7175.                     T:GoTo(ssx, SY+1, ssz)
  7176.                    
  7177.                     T:TurnLeft()
  7178.                    
  7179.                     local succes1 = T.detect()
  7180.                    
  7181.                     for _ = 1, 2 do T:TurnRight() end
  7182.                    
  7183.                     local succes2 = T.detect()
  7184.                    
  7185.                     T:TurnLeft()
  7186.                    
  7187.                     if succes1 or succes2 then
  7188.                         local sxx, szz = T:getx(), T:getZ()
  7189.                         T:Forward()
  7190.                        
  7191.                         if T:getX() == sxx then
  7192.                             T:GoTo(sxx, SY+1, ssz)
  7193.                         elseif T:getz() == szz then
  7194.                             T:GoTo(ssx, SY+1, szz)
  7195.                         end
  7196.                        
  7197.                     end
  7198.                    
  7199.                     T:GoTo(ssx, SY+1, ssz)
  7200.                     T:GoTo(ssx, SY+1, ssz)
  7201.                     T:GoTo(ssx, SY, ssz)
  7202.                     T:GoTo(ssx, ssy, ssz)
  7203.                     T:TurnDirection(ssr)
  7204.                    
  7205.                 end
  7206.                
  7207.                 T.select(Torchslots[1])
  7208.                 T:Up()
  7209.                 T.placeDown()
  7210.                
  7211.             end
  7212.            
  7213.             T:TurnLeft()
  7214.            
  7215.             T.select(1)
  7216.            
  7217.             while T.dig() do end
  7218.            
  7219.             T:Forward()
  7220.            
  7221.             while T:getY() > SY do
  7222.                
  7223.                 T.digDown()
  7224.                 T:Down()
  7225.                
  7226.             end
  7227.            
  7228.             while T:getY() < SY do
  7229.                
  7230.                 while T.digUp() do end
  7231.                 T:Up()
  7232.                
  7233.             end
  7234.            
  7235.             while T.digUp() do end
  7236.            
  7237.             Succes, Detail = T.inspectDown()
  7238.             a = 0
  7239.            
  7240.             while not(Succes) do
  7241.                
  7242.                 T:Down()
  7243.                
  7244.                 if T:getY() < 7 then
  7245.                    
  7246.                     a = T:Add(a, 1)
  7247.                     checkForOre()
  7248.                     T.select(Stoneslots[1])
  7249.                    
  7250.                     T:SortInvItems(2)
  7251.                     Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  7252.                    
  7253.                     local stonecount = T.getItemCount(Stoneslots[1])
  7254.                    
  7255.                     if stonecount < 10 then
  7256.                        
  7257.                         local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  7258.                        
  7259.                         T:GoTo(ssx, SY+1, ssz)
  7260.                         T:GoTo(Mine.x, SY+1, Mine.z)
  7261.                         T:GoTo(Mine.x, SY+1, Mine.z)
  7262.                         T:GoTo(Mine.x, SY+1, Mine.z)
  7263.                         T:GoTo(Mine.x, SY+1, Mine.z)
  7264.                         T:GoTo(Mine.x, Mine.y, Mine.z)
  7265.                        
  7266.                         T:Refuel()
  7267.                         GetChest()
  7268.                         GetModem()
  7269.                        
  7270.                         Stone, mess = T:GetItemFromChest("stone", "cobblestone", 32, 2)
  7271.                        
  7272.                         if not(Stone) then
  7273.                            
  7274.                             Generate(32, 2)
  7275.                            
  7276.                         end
  7277.                        
  7278.                         T:GoTo(Mine.x, Mine.y, Mine.z)
  7279.                         T:GoTo(Mine.x, SY+1, Mine.z)
  7280.                         T:GoTo(ssx, SY+1, ssz)
  7281.                        
  7282.                         T:TurnLeft()
  7283.                        
  7284.                         local succes1 = T.detect()
  7285.                        
  7286.                         for _ = 1, 2 do T:TurnRight() end
  7287.                        
  7288.                         local succes2 = T.detect()
  7289.                        
  7290.                         T:TurnLeft()
  7291.                        
  7292.                         if succes1 or succes2 then
  7293.                             local sxx, szz = T:getx(), T:getZ()
  7294.                             T:Forward()
  7295.                            
  7296.                             if T:getX() == sxx then
  7297.                                 T:GoTo(sxx, SY+1, ssz)
  7298.                             elseif T:getz() == szz then
  7299.                                 T:GoTo(ssx, SY+1, szz)
  7300.                             end
  7301.                            
  7302.                         end
  7303.                        
  7304.                         T:GoTo(ssx, SY+1, ssz)
  7305.                         T:GoTo(ssx, SY+1, ssz)
  7306.                         T:GoTo(ssx, SY, ssz)
  7307.                         T:GoTo(ssx, ssy, ssz)
  7308.                         T:TurnDirection(ssr)
  7309.                        
  7310.                     end
  7311.                    
  7312.                     for b = 1, 4 do
  7313.                         T:TurnLeft()
  7314.                         T.place()
  7315.                     end
  7316.                     T.select(1)
  7317.                    
  7318.                 end
  7319.                
  7320.                 Succes, Detail = T.inspectDown()
  7321.                
  7322.             end
  7323.            
  7324.             while Succes and Detail.name ~= "minecraft:bedrock" do
  7325.                
  7326.                 T.digDown()
  7327.                 T:Down()
  7328.                 a = T:Add(a, 1)
  7329.                 checkForOre()
  7330.                 T.select(Stoneslots[1])
  7331.                
  7332.                 T:SortInvItems(2)
  7333.                 Stonenumber, Stoneslots = T:LookInvItems("cobblestone", true)
  7334.                
  7335.                 local stonecount = T.getItemCount(Stoneslots[1])
  7336.                
  7337.                 if stonecount < 10 then
  7338.                    
  7339.                     local ssx, ssy, ssz, ssr = T:getX(), T:getY(), T:getZ(), T:getR()
  7340.                    
  7341.                     T:GoTo(ssx, SY+1, ssz)
  7342.                     T:GoTo(ssx, SY+1, ssz)
  7343.                    
  7344.                     T:TurnLeft()
  7345.                    
  7346.                     local succes1 = T.detect()
  7347.                    
  7348.                     for _ = 1, 2 do T:TurnRight() end
  7349.                    
  7350.                     local succes2 = T.detect()
  7351.                    
  7352.                     T:TurnLeft()
  7353.                    
  7354.                     if succes1 or succes2 then
  7355.                         local sxx, szz = T:getx(), T:getZ()
  7356.                         T:Forward()
  7357.                        
  7358.                         if T:getX() == sxx then
  7359.                             T:GoTo(sxx, SY+1, ssz)
  7360.                         elseif T:getz() == szz then
  7361.                             T:GoTo(ssx, SY+1, szz)
  7362.                         end
  7363.                        
  7364.                     end
  7365.                    
  7366.                     T:GoTo(ssx, SY+1, ssz)
  7367.                     T:GoTo(ssx, SY+1, ssz)
  7368.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  7369.                    
  7370.                     T:Refuel()
  7371.                     GetChest()
  7372.                     GetModem()
  7373.                    
  7374.                     Stone, mess = T:GetItemFromChest("stone", "cobblestone", 32, 2)
  7375.                    
  7376.                     if not(Stone) then
  7377.                        
  7378.                         Generate(32, 2)
  7379.                        
  7380.                     end
  7381.                    
  7382.                     T:GoTo(Mine.x, Mine.y, Mine.z)
  7383.                     T:GoTo(Mine.x, SY+1, Mine.z)
  7384.                     T:GoTo(ssx, SY+1, ssz)
  7385.                     T:GoTo(ssx, SY+1, ssz)
  7386.                     T:GoTo(ssx, SY+1, ssz)
  7387.                     T:GoTo(ssx, SY+1, ssz)
  7388.                     T:GoTo(ssx, SY, ssz)
  7389.                     T:GoTo(ssx, ssy, ssz)
  7390.                     T:TurnDirection(ssr)
  7391.                    
  7392.                 end
  7393.                
  7394.                 for b = 1, 4 do
  7395.                     T:TurnLeft()
  7396.                     T.place()
  7397.                 end
  7398.                 T.select(1)
  7399.                 Succes, Detail = T.inspectDown()
  7400.                
  7401.             end
  7402.            
  7403.             for b = 1, a do
  7404.                
  7405.                 T.select(Stoneslots[1])
  7406.                 T:Up()
  7407.                 T.placeDown()
  7408.                
  7409.             end
  7410.            
  7411.             T:TurnLeft()
  7412.            
  7413.         end
  7414.        
  7415.     end
  7416.    
  7417.     T:SortInvItems(1)
  7418.    
  7419.     T:GoHome()
  7420.     SortStorage()
  7421.     T:Refuel()
  7422.     GetModem()
  7423.    
  7424.     Status = 17
  7425.    
  7426.     SaveFile("status")
  7427.    
  7428. end
  7429.  
  7430. function MakeLadder() -- 7 sticks = 3 ladders -- 2 planks = 4 sticks -- 1 log = 4 planks
  7431.    
  7432.     SaveFile("log", "Making Ladder", true)
  7433.    
  7434.     local stick, mess = T:GetItemFromChest("wood", "stick", 7, 4)
  7435.    
  7436.     if not(stick) then
  7437.        
  7438.         local planks, mess = T:GetItemFromChest("wood", "planks", 4, 4)
  7439.        
  7440.         if not(planks) then
  7441.            
  7442.             local logs, mess = T:GetItemFromChest("wood", "log", 1, 4)
  7443.            
  7444.             while not(logs) do
  7445.                
  7446.                 HarvestTreeFarm()
  7447.                 logs, mess = T:GetItemFromChest("wood", "log", 1, 4)
  7448.                
  7449.             end
  7450.            
  7451.             T:Craft("planks", 4, "log")
  7452.            
  7453.         end
  7454.        
  7455.         T:Craft("stick", 7, "planks")
  7456.        
  7457.     end
  7458.    
  7459.     T:Craft("ladder", 3, "stick")
  7460.    
  7461.     GetChest()
  7462.    
  7463. end
  7464.  
  7465. function PlaceLadder()
  7466.  
  7467.     SaveFile("log", "Getting Ladder", true)
  7468.    
  7469.     local ladder, mess, N = T:GetItemFromChest("wood", "ladder", 63, 4)
  7470.    
  7471.     while not(ladder) do
  7472.         N = math.ceil((63 - N) / 3)
  7473.         for _ = 1, N do
  7474.             MakeLadder()
  7475.         end
  7476.         GetModem()
  7477.         SortStorage(2)
  7478.         ladder, mess, N = T:GetItemFromChest("wood", "ladder", 63, 4)
  7479.     end
  7480.    
  7481.     SaveFile("log", "Getting Cobblestone", true)
  7482.    
  7483.     local stone, mess = T:GetItemFromChest("stone", "cobblestone", 64, 8)
  7484.    
  7485.     if not(stone) then
  7486.         Generate(64, 8)
  7487.     end
  7488.    
  7489.     local stonenumber, stoneslots = T:LookInvItems("cobblestone", true)
  7490.     local laddernumber, ladderslots = T:LookInvItems("ladder", true)
  7491.    
  7492.     SaveFile("log", "Placeing Cobblestone", true)
  7493.    
  7494.     T:GoTo(Mine.x, Mine.y, Mine.z)
  7495.     T:Up()
  7496.     T:Forward()
  7497.    
  7498.     T.select(stoneslots[1])
  7499.    
  7500.     while T:getY() > 7 do
  7501.        
  7502.         T.digDown()
  7503.         T:Down()
  7504.         T.dig()
  7505.         T.place()
  7506.         T:TurnLeft()
  7507.         T.dig()
  7508.         T.place()
  7509.        
  7510.         for i = 1, 2 do
  7511.             T:TurnRight()
  7512.         end
  7513.        
  7514.         T.dig()
  7515.         T.place()
  7516.        
  7517.         T:TurnLeft()
  7518.        
  7519.     end
  7520.    
  7521.     T:Back()
  7522.    
  7523.     T.select(ladderslots[1])
  7524.    
  7525.     SaveFile("log", "Placeing Ladder", true)
  7526.    
  7527.     while T:getY() < (Mine.y + 1) do
  7528.        
  7529.         T.place()
  7530.         T:Up()
  7531.        
  7532.     end
  7533.    
  7534.     SortStorage()
  7535.     T:Refuel()
  7536.     GetModem()
  7537.    
  7538.     Status = 18
  7539.    
  7540.     SaveFile("status")
  7541.    
  7542. end
  7543.  
  7544. function MakeShaft()
  7545.    
  7546.     SaveFile("log", "Getting Cobblestone", true)
  7547.    
  7548.     local stone, mess = T:GetItemFromChest("stone", "cobblestone", 64, 8)
  7549.    
  7550.     if not(stone) then
  7551.         Generate(64, 8)
  7552.     end
  7553.    
  7554.     local stonenumber, stoneslots = T:LookInvItems("cobblestone", true)
  7555.    
  7556.     SaveFile("log", "Makeing Mine Shaft", true)
  7557.    
  7558.     T:GoTo(Mine.x, Mine.y, Mine.z)
  7559.     T:Down()
  7560.    
  7561.     for i = 1, 2 do T:TurnRight() end
  7562.    
  7563.     T.select(stoneslots[1])
  7564.    
  7565.     while T:getY() > 22 do
  7566.        
  7567.         T.dig()
  7568.         T.place()
  7569.        
  7570.         T:TurnLeft()
  7571.         T.dig()
  7572.         T.place()
  7573.        
  7574.         for i = 1, 2 do T:TurnRight() end
  7575.        
  7576.         T.dig()
  7577.         T.place()
  7578.        
  7579.         T:TurnLeft()
  7580.        
  7581.         T:Down()
  7582.        
  7583.     end
  7584.    
  7585.     T:TurnLeft()
  7586.    
  7587.     while T:getY() > 7 do
  7588.        
  7589.         T.dig()
  7590.         T.place()
  7591.        
  7592.         for i = 1, 2 do T:TurnRight() end
  7593.        
  7594.         T.dig()
  7595.         T.place()
  7596.        
  7597.         for i = 1, 2 do T:TurnLeft() end
  7598.        
  7599.         T:Down()
  7600.        
  7601.     end
  7602.    
  7603.     T:GoTo(Mine.x, Mine.y, Mine.z)
  7604.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  7605.     T:TurnDirection(T:getHomeR())
  7606.     SortStorage()
  7607.     T:Refuel()
  7608.     GetModem()
  7609.    
  7610.     Status = 19
  7611.    
  7612.     SaveFile("status")
  7613.    
  7614. end
  7615.  
  7616. function SandInspect()
  7617.    
  7618.     local succes, details = T.inspectDown()
  7619.    
  7620.     if succes and details.name == ("minecraft:sand" or "minecraft:red_sand") then
  7621.        
  7622.         T.digDown()
  7623.         T:Down()
  7624.         SandInspect()
  7625.         T:Up()
  7626.        
  7627.     end
  7628.    
  7629.     for i = 1, 4 do
  7630.        
  7631.         succes, details = T.inspect()
  7632.        
  7633.         if succes and details.name == ("minecraft:sand" or "minecraft:red_sand") then
  7634.            
  7635.             T.dig()
  7636.             T:Forward()
  7637.             SandInspect()
  7638.             T:Back()
  7639.            
  7640.         end
  7641.        
  7642.         T:TurnLeft()
  7643.        
  7644.     end
  7645.    
  7646. end
  7647.  
  7648. function GetSand(count, slot)
  7649.    
  7650.     SaveFile("log", "Getting Sand", true)
  7651.    
  7652.     T:GoTo(T:getX(), 100, T:getZ())
  7653.     T:GoTo(Sand.x, 100, Sand.z)
  7654.     T:GoTo(Sand.x, Sand.y, Sand.z)
  7655.    
  7656.     T.select(slot)
  7657.     SandInspect()
  7658.    
  7659.     if T.getItemCount(slot) < count then
  7660.        
  7661.         local a = 1
  7662.        
  7663.         while T.getItemCount(slot) < count do
  7664.            
  7665.             for j = 1, 2 do
  7666.                
  7667.                 for I = 1, a do
  7668.                    
  7669.                     T:Forward()
  7670.                     SandInspect()
  7671.                    
  7672.                 end
  7673.                
  7674.                 T:TurnRight()
  7675.                
  7676.             end
  7677.            
  7678.             a = T:Add(a, 1)
  7679.            
  7680.         end
  7681.        
  7682.         Sand.x, Sand.y, Sand.z = T:getX(), T:getY(), T:getZ()
  7683.         SaveFile("locations")
  7684.        
  7685.     end
  7686.    
  7687. end
  7688.  
  7689. function MakeSugarCaneFarm()
  7690.    
  7691.     GetBucket()
  7692.    
  7693.     local sand, mess = T:GetItemFromChest("sand", "sand", 5, 8)
  7694.    
  7695.     if not(sand) then
  7696.         GetSand(5, 8)
  7697.     end
  7698.    
  7699.     local sugar, mess = T:GetItemFromChest("sand", "sugar_cane", 5, 4)
  7700.    
  7701.     if not(sugar) then
  7702.        
  7703.         SaveFile("log", mess, true)
  7704.         error()
  7705.        
  7706.     end
  7707.    
  7708.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  7709.     T:TurnDirection(T:getHomeR())
  7710.    
  7711.     T:TurnRight()
  7712.    
  7713.     for i = 1, 3 do
  7714.         T.dig()
  7715.         T:Forward()
  7716.         T:checkUp()
  7717.     end
  7718.    
  7719.     for i = 1, 5 do
  7720.        
  7721.         local sx, sy, sz, sr = T:getX(), T:getY(), T:getZ(), T:getR()
  7722.        
  7723.         T.select(bucketSlot)
  7724.        
  7725.         T:GoTo(T:getX(), 100, T:getZ())
  7726.         T:GoTo(Water.x, 100, Water.z)
  7727.         T:GoTo(Water.x, Water.y, Water.z)
  7728.        
  7729.         T.placeDown()
  7730.        
  7731.         T:GoTo(T:getX(), 100, T:getZ())
  7732.         T:GoTo(sx, 100, sz)
  7733.         T:GoTo(sx, sy, sz)
  7734.         T:TurnDirection(sr)
  7735.        
  7736.         T.digDown()
  7737.         T.placeDown()
  7738.        
  7739.         if i < 5 then
  7740.             T.dig()
  7741.             T:Forward()
  7742.             T:checkUp()
  7743.         end
  7744.        
  7745.     end
  7746.    
  7747.     T:TurnRight()
  7748.     T.dig()
  7749.     T:Forward()
  7750.     T:checkUp()
  7751.     T:TurnRight()
  7752.    
  7753.     for i = 1, 5 do
  7754.        
  7755.         T.select(8)
  7756.        
  7757.         T.digDown()
  7758.         T.placeDown()
  7759.         T:Up()
  7760.         T.select(4)
  7761.         T.placeDown()
  7762.        
  7763.         if i < 5 then
  7764.             T.dig()
  7765.             T:Forward()
  7766.             T:checkUp()
  7767.             T.digDown()
  7768.             T:Down()
  7769.         end
  7770.        
  7771.     end
  7772.    
  7773.     SortStorage()
  7774.     T:Refuel()
  7775.     GetModem()
  7776.    
  7777. end
  7778.  
  7779. function GetSugarCane()
  7780.    
  7781.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  7782.     T:TurnDirection(T:getHomeR())
  7783.    
  7784.     T:Back()
  7785.     T:TurnRight()
  7786.    
  7787.     for i = 1, 2 do T:Forward() end
  7788.    
  7789.     local succes, details = T.inspect()
  7790.    
  7791.     if not(succes) or (succes and details.name ~= "minecraft:sugar_cane") then
  7792.        
  7793.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  7794.         T:TurnDirection(T:getHomeR())
  7795.        
  7796.         MakeSugarCaneFarm()
  7797.        
  7798.         T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  7799.         T:TurnDirection(T:getHomeR())
  7800.        
  7801.         T:Back()
  7802.         T:TurnRight()
  7803.        
  7804.         for i = 1, 2 do T:Forward() end
  7805.        
  7806.     end
  7807.    
  7808.     for i = 1, 3 do T:Up() end
  7809.    
  7810.     T:Forward()
  7811.    
  7812.     for i = 1, 5 do
  7813.        
  7814.         local succes, details = T.inspectDown()
  7815.        
  7816.         while not(succes) do
  7817.             sleep(5)
  7818.             succes, details = T.inspectDown()
  7819.         end
  7820.        
  7821.         if succes then
  7822.            
  7823.             T.digDown()
  7824.             T:Down()
  7825.             T.digDown()
  7826.             T:Up()
  7827.            
  7828.         end
  7829.        
  7830.         if i < 5 then
  7831.             T:Forward()
  7832.         end
  7833.        
  7834.     end
  7835.    
  7836.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  7837.     T:TurnDirection(T:getHomeR())
  7838.    
  7839.     SortStorage()
  7840.     T:Refuel()
  7841.     GetModem()
  7842.    
  7843. end
  7844.  
  7845. function MakeGlass()
  7846.    
  7847.     local logs, mess = T:GetItemFromChest("wood", "log", 4, 4)
  7848.    
  7849.     while not(logs) do
  7850.        
  7851.         HarvestTreeFarm()
  7852.         logs, mess = T:GetItemFromChest("wood", "log", 4, 4)
  7853.        
  7854.     end
  7855.    
  7856.     local sand, mess = T:GetItemFromChest("sand", "sand", 6, 8)
  7857.    
  7858.     if not(sand) then
  7859.         GetSand(6, 8)
  7860.     end
  7861.    
  7862.     T:GoHome()
  7863.    
  7864.     for i = 1, 2 do T:Up() end
  7865.     for i = 1, 2 do T:Forward() end
  7866.    
  7867.     local logcount, logslots = T:LookInvItems("log", true)
  7868.     local sandcount, sandslots = T:LookInvItems("sand", true)
  7869.    
  7870.     T.select(sandslots[1])
  7871.     T.dropDown(6)
  7872.    
  7873.     T:Back()
  7874.     T:Down()
  7875.    
  7876.     T.select(logslots[1])
  7877.     T.drop(4)
  7878.    
  7879.     T:Down()
  7880.     T:Forward()
  7881.    
  7882.     sleep(60)
  7883.    
  7884.     while T.suckUp() do end
  7885.    
  7886.     SortStorage()
  7887.    
  7888.     GetChest()
  7889.     GetModem()
  7890.    
  7891. end
  7892.  
  7893. function MakeGlasPane()
  7894.    
  7895.     local glas, mess = T:GetItemFromChest("sand", "glas", 6, 4)
  7896.    
  7897.     while not(glas) do
  7898.        
  7899.         MakeGlass()
  7900.         glas, mess = T:GetItemFromChest("sand", "glas", 6, 4)
  7901.        
  7902.     end
  7903.    
  7904.     local glascount, glasslots = T:LookInvItems("glas", true)
  7905.    
  7906.     T.select(glasslots[1])
  7907.     T.transferTo(1,1)
  7908.     T.transferTo(2,1)
  7909.     T.transferTo(3,1)
  7910.     T.transferTo(5,1)
  7911.     T.transferTo(6,1)
  7912.     T.transferTo(7,1)
  7913.     T.dropDown()
  7914.     T.select(8)
  7915.     T.dropDown()
  7916.     T.select(9)
  7917.     T.dropDown()
  7918.     T.select(10)
  7919.     T.dropDown()
  7920.     T.select(11)
  7921.     T.dropDown()
  7922.     T.select(12)
  7923.     T.dropDown()
  7924.     T.select(13)
  7925.     T.dropDown()
  7926.     T.select(14)
  7927.     T.dropDown()
  7928.     T.select(15)
  7929.     T.dropDown()
  7930.     T.select(16)
  7931.     T.dropDown()
  7932.     T.select(glasslots[1])
  7933.     T.craft()
  7934.    
  7935.     GetChest()
  7936.     GetModem()
  7937.    
  7938.     SortStorage()
  7939.    
  7940. end
  7941.  
  7942. function ProgramDisk()
  7943.    
  7944.     local diskdrive, mess = T:GetItemFromChest("rest", "computercraft:disk_drive", 1, 1, false)
  7945.     local Disk, mess = T:GetItemFromChest("rest", "computercraft:disk", 1, 2, false)
  7946.    
  7947.     T.select(1)
  7948.     T.place()
  7949.     T.select(2)
  7950.     T.drop()
  7951.    
  7952.     disk.setLabel("front", "Turle_Setup")
  7953.    
  7954.     local file = fs.open("disk/startup.lua", "w")
  7955.     file.write('shell.run("pastebin get V2Cv9a0M /SelfRep.lua")')
  7956.     file.close()
  7957.    
  7958.     T.suck()
  7959.     T.select(1)
  7960.     T.dig()
  7961.    
  7962. end
  7963.  
  7964. function CraftDiskDive()
  7965.    
  7966.     local stone, mess = T:GetItemFromChest("stone", "cobblestone", 7, 1)
  7967.    
  7968.     if not(stone) then
  7969.         Generate(7, 1)
  7970.     end
  7971.    
  7972.     local logs, mess = T:GetItemFromChest("wood", "log", 5, 8)
  7973.    
  7974.     while not(logs) do
  7975.        
  7976.         HarvestTreeFarm()
  7977.         logs, mess = T:GetItemFromChest("wood", "log", 6, 8)
  7978.        
  7979.     end
  7980.    
  7981.     T:GoTo(Chests[1])
  7982.    
  7983.     for i = 1, 2 do T:TurnLeft() end
  7984.    
  7985.     T:Back()
  7986.    
  7987.     for i = 1, 2 do T:Up() end
  7988.    
  7989.     T:Forward()
  7990.     T.select(1)
  7991.     T.dropDown()
  7992.     T:Back()
  7993.     T:Down()
  7994.     T.select(8)
  7995.     T.drop()
  7996.     T:Down()
  7997.     T:Forward()
  7998.     T.select(1)
  7999.    
  8000.     sleep(70)
  8001.    
  8002.     while T.suckUp() do sleep(5) end
  8003.    
  8004.     T.transferTo(2,1)
  8005.     T.transferTo(3,1)
  8006.     T.transferTo(5,1)
  8007.     T.transferTo(7,1)
  8008.     T.transferTo(9,1)
  8009.     T.transferTo(11,1)
  8010.    
  8011.     local redstone, mess = T:GetItemFromChest("redstone", "redstone", 2, 6)
  8012.    
  8013.     T.select(6)
  8014.     T.transferTo(10,1)
  8015.    
  8016.     T:GoTo(Chests[1])
  8017.    
  8018.     for i = 1, 2 do T:TurnLeft() end
  8019.    
  8020.     T.select(chestSlot)
  8021.     T.dropDown()
  8022.     T.select(modemSlot)
  8023.     T.dropDown()
  8024.     T.craft()
  8025.     T.dropDown()
  8026.    
  8027.     GetChest()
  8028.     GetModem()
  8029.    
  8030.     SortStorage(2)
  8031.    
  8032.     local dye, mess = T:GetItemFromChest("rest", "minecraft:white_dye", 1, 5)
  8033.    
  8034.     if not(dye) then
  8035.        
  8036.         local meal, mess = T:GetItemFromChest("sapling", "minecraft:bone_meal", 1, 5)
  8037.        
  8038.         if not(meal) then
  8039.            
  8040.             local bone, mess = T:GetItemFromChest("sapling", "minecraft:bone", 1, 4)
  8041.            
  8042.             while not(bone) do
  8043.                 AttackMobs(3)
  8044.                 bone, mess = T:GetItemFromChest("sapling", "minecraft:bone", 1, 4)
  8045.             end
  8046.            
  8047.             T:Craft("bone_meal", 1, "bone")
  8048.            
  8049.         end
  8050.        
  8051.         T:Craft("white_dye", 1, "bone_meal")
  8052.        
  8053.     end
  8054.    
  8055.     T.select(5)
  8056.     T.dropDown()
  8057.    
  8058.     GetChest()
  8059.     GetModem()
  8060.    
  8061.     SortStorage(2)
  8062.    
  8063.     local paper, mess = T:GetItemFromChest("sand", "paper", 1, 2)
  8064.    
  8065.     if not(paper) then
  8066.        
  8067.         local sugar, mess = T:GetItemFromChest("sand", "sugar_cane", 3, 4)
  8068.        
  8069.         if not(sugar) then
  8070.            
  8071.             GetSugarCane()
  8072.             sugar, mess = T:GetItemFromChest("sand", "sugar_cane", 3, 4)
  8073.         end
  8074.        
  8075.         T:Craft("paper", 1, "sugar_cane")
  8076.        
  8077.     end
  8078.    
  8079.     T.select(2)
  8080.     T.dropDown()
  8081.    
  8082.     GetChest()
  8083.     GetModem()
  8084.    
  8085.     SortStorage(2)
  8086.    
  8087.     local bone, mess = T:GetItemFromChest("rest", "minecraft:white_dye", 1, 5)
  8088.     local paper, mess = T:GetItemFromChest("sand", "paper", 1, 2)
  8089.     local redstone, mess = T:GetItemFromChest("redstone", "redstone", 1, 1)
  8090.    
  8091.     T:GoTo(Chests[1])
  8092.    
  8093.     for i = 3, 4 do
  8094.         T.select(i)
  8095.         T.dropDown()
  8096.     end
  8097.    
  8098.     for i = 6, 16 do
  8099.         T.select(i)
  8100.         T.dropDown()
  8101.     end
  8102.    
  8103.     T.craft()
  8104.    
  8105.     GetChest()
  8106.     T:Refuel()
  8107.     GetModem()
  8108.    
  8109.     SortStorage(2)
  8110.    
  8111.     ProgramDisk()
  8112.    
  8113.     SortStorage()
  8114.    
  8115.     Status = 20
  8116.    
  8117.     SaveFile("status")
  8118.    
  8119. end
  8120.  
  8121. function CraftTurtle()
  8122.    
  8123.     GetChest()
  8124.     GetModem()
  8125.    
  8126.     SaveFile("log", "Craft Turtle", true)
  8127.    
  8128.     MakePickAxe()
  8129.    
  8130.     GetChest()
  8131.     GetModem()
  8132.    
  8133.     local logs, mess = T:GetItemFromChest("wood", "log", 20, 8)
  8134.    
  8135.     while not(logs) do
  8136.        
  8137.         HarvestTreeFarm()
  8138.         logs, mess = T:GetItemFromChest("wood", "log", 20, 8)
  8139.        
  8140.     end
  8141.    
  8142.     GetChest()
  8143.     GetModem()
  8144.    
  8145.     SortStorage(2)
  8146.    
  8147.     logs, mess = T:GetItemFromChest("wood", "log", 1, 1)
  8148.    
  8149.     T:Craft("planks", 4, "log")
  8150.    
  8151.     GetChest()
  8152.     GetModem()
  8153.    
  8154.     SortStorage(2)
  8155.    
  8156.     logs, mess = T:GetItemFromChest("wood", "planks", 4, 4)
  8157.     local planksnumber, planksslots = T:LookInvItems("planks", true)   
  8158.    
  8159.     T.select(planksslots[1])
  8160.     T.transferTo(1,1)
  8161.     T.transferTo(2,1)
  8162.     T.transferTo(5,1)
  8163.     T.transferTo(6,1)
  8164.    
  8165.     for i = 3, 4 do
  8166.         T.select(i)
  8167.         T.dropDown()
  8168.     end
  8169.    
  8170.     for i = 7, 16 do
  8171.         T.select(i)
  8172.         T.dropDown()
  8173.     end
  8174.    
  8175.     T.craft()
  8176.    
  8177.     GetChest()
  8178.     GetModem()
  8179.    
  8180.     SortStorage(2)
  8181.    
  8182.     local glas, mess = T:GetItemFromChest("sand", "glass_pane", 1, 10)
  8183.    
  8184.     while not(glas) do
  8185.        
  8186.         MakeGlasPane()
  8187.         glas, mess = T:GetItemFromChest("sand", "glass_pane", 1, 10)
  8188.        
  8189.     end
  8190.    
  8191.     local stone, mess = T:GetItemFromChest("stone", "cobblestone", 7, 1)
  8192.    
  8193.     if not(stone) then
  8194.         Generate(7, 1)
  8195.     end
  8196.    
  8197.     logs, mess = T:GetItemFromChest("wood", "log", 5, 8)
  8198.    
  8199.     T:GoTo(Chests[1])
  8200.    
  8201.     for i = 1, 2 do T:TurnLeft() end
  8202.    
  8203.     T:Back()
  8204.    
  8205.     for i = 1, 2 do T:Up() end
  8206.    
  8207.     T:Forward()
  8208.     T.select(1)
  8209.     T.dropDown()
  8210.     T:Back()
  8211.     T:Down()
  8212.     T.select(8)
  8213.     T.drop()
  8214.     T:Down()
  8215.     T:Forward()
  8216.     T.select(1)
  8217.    
  8218.     sleep(70)
  8219.    
  8220.     while T.suckUp() do sleep(5) end
  8221.    
  8222.     T.transferTo(2,1)
  8223.     T.transferTo(3,1)
  8224.     T.transferTo(5,1)
  8225.     T.transferTo(7,1)
  8226.     T.transferTo(9,1)
  8227.     T.transferTo(11,1)
  8228.    
  8229.     local redstone, mess = T:GetItemFromChest("redstone", "redstone", 1, 6)
  8230.    
  8231.     T:GoTo(Chests[1])
  8232.    
  8233.     for i = 1, 2 do T:TurnLeft() end
  8234.    
  8235.     T.select(chestSlot)
  8236.     T.dropDown()
  8237.     T.select(modemSlot)
  8238.     T.dropDown()
  8239.     T.craft()
  8240.     T.dropDown()
  8241.    
  8242.     GetChest()
  8243.     GetModem()
  8244.    
  8245.     SortStorage(2)
  8246.    
  8247.     local pearl, mess = T:GetItemFromChest("rest", "ender_pearl", 1, 6)
  8248.    
  8249.     while not(pearl) do
  8250.         AttackMobs(2)
  8251.         pearl, mess = T:GetItemFromChest("rest", "ender_pearl", 1, 6)
  8252.     end
  8253.    
  8254.     local stone, mess = T:GetItemFromChest("stone", "cobblestone", 8, 1)
  8255.    
  8256.     if not(stone) then
  8257.         Generate(8, 1)
  8258.     end
  8259.    
  8260.     logs, mess = T:GetItemFromChest("wood", "log", 6, 8)
  8261.    
  8262.     T:GoTo(Chests[1])
  8263.    
  8264.     for i = 1, 2 do T:TurnLeft() end
  8265.    
  8266.     T:Back()
  8267.    
  8268.     for i = 1, 2 do T:Up() end
  8269.    
  8270.     T:Forward()
  8271.     T.select(1)
  8272.     T.dropDown()
  8273.     T:Back()
  8274.     T:Down()
  8275.     T.select(8)
  8276.     T.drop()
  8277.     T:Down()
  8278.     T:Forward()
  8279.     T.select(1)
  8280.    
  8281.     sleep(80)
  8282.    
  8283.     while T.suckUp() do sleep(5) end
  8284.    
  8285.     T.transferTo(2,1)
  8286.     T.transferTo(3,1)
  8287.     T.transferTo(5,1)
  8288.     T.transferTo(7,1)
  8289.     T.transferTo(9,1)
  8290.     T.transferTo(10,1)
  8291.     T.transferTo(11,1)
  8292.     T.select(4)
  8293.     T.dropDown()
  8294.     T.select(8)
  8295.     T.dropDown()
  8296.    
  8297.     for i = 12, 16 do
  8298.        
  8299.         T.select(i)
  8300.         T.dropDown()
  8301.        
  8302.     end
  8303.    
  8304.     T.craft()
  8305.    
  8306.     GetChest()
  8307.     GetModem()
  8308.     SortStorage(2)
  8309.    
  8310.     local iron, mess = T:GetItemFromChest("iron", "iron_ore", 7, 4)
  8311.    
  8312.     if not(iron) then
  8313.        
  8314.         SaveFile("log", mess, true)
  8315.         error()
  8316.        
  8317.     end
  8318.    
  8319.     logs, mess = T:GetItemFromChest("wood", "log", 5, 8)
  8320.    
  8321.     T:GoTo(Chests[1])
  8322.    
  8323.     for i = 1, 2 do T:TurnLeft() end
  8324.    
  8325.     T:Back()
  8326.    
  8327.     for i = 1, 2 do T:Up() end
  8328.    
  8329.     T:Forward()
  8330.     T.select(4)
  8331.     T.dropDown()
  8332.     T:Back()
  8333.     T:Down()
  8334.     T.select(8)
  8335.     T.drop()
  8336.     T:Down()
  8337.     T:Forward()
  8338.     T.select(4)
  8339.    
  8340.     sleep(70)
  8341.    
  8342.     while T.suckUp() do sleep(5) end
  8343.    
  8344.     GetChest()
  8345.     GetModem()
  8346.     SortStorage(2)
  8347.    
  8348.     logs, mess = T:GetItemFromChest("wood", "log", 2, 4)
  8349.    
  8350.     T:Craft("planks", 8, "log")
  8351.     T:Craft("chest", 1, "planks")
  8352.    
  8353.     GetChest()
  8354.     GetModem()
  8355.     SortStorage(2)
  8356.    
  8357.     local iron, mess = T:GetItemFromChest("iron", "iron_ingot", 7, 1)
  8358.     local chest, mess1 = T:GetItemFromChest("rest", "chest", 1, 10)
  8359.     local computer, mess2 = T:GetItemFromChest("rest", "computercraft:computer", 1, 6)
  8360.    
  8361.     if not(iron) then
  8362.        
  8363.         SaveFile("log", mess, true)
  8364.         error()
  8365.        
  8366.     end
  8367.    
  8368.     if not(chest) then
  8369.        
  8370.         SaveFile("log", mess1, true)
  8371.         error()
  8372.        
  8373.     end
  8374.    
  8375.     if not(computer) then
  8376.        
  8377.         SaveFile("log", mess2, true)
  8378.         error()
  8379.        
  8380.     end
  8381.    
  8382.     T.select(1)
  8383.     T.transferTo(2,1)
  8384.     T.transferTo(3,1)
  8385.     T.transferTo(5,1)
  8386.     T.transferTo(7,1)
  8387.     T.transferTo(9,1)
  8388.     T.transferTo(11,1)
  8389.    
  8390.     T.select(4)
  8391.     T.dropDown()
  8392.     T.select(8)
  8393.     T.dropDown()
  8394.    
  8395.     for i = 12, 16 do
  8396.        
  8397.         T.select(i)
  8398.         T.dropDown()
  8399.        
  8400.     end
  8401.    
  8402.     T.craft()
  8403.    
  8404.     GetChest()
  8405.     GetModem()
  8406.     SortStorage(2)
  8407.    
  8408.     local computer, mess2 = T:GetItemFromChest("diamond", "pickaxe", 1, 3)
  8409.     local iron, mess = T:GetItemFromChest("rest", "modem", 1, 1)
  8410.     local chest, mess1 = T:GetItemFromChest("rest", "turtle", 1, 2)
  8411.    
  8412.     for i = 4, 16 do
  8413.        
  8414.         T.select(i)
  8415.         T.dropDown()
  8416.        
  8417.     end
  8418.    
  8419.     T.select(4)
  8420.    
  8421.     T.craft()
  8422.    
  8423.     GetChest()
  8424.     GetModem()
  8425.     SortStorage(2)
  8426.    
  8427.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  8428.     T:TurnDirection(T:getHomeR())
  8429.    
  8430. end
  8431.  
  8432. function ProgramTurtle()
  8433.    
  8434.     GetChest()
  8435.     GetModem()
  8436.    
  8437.     SaveFile("log", "Programming Turtle", true)
  8438.    
  8439.     local Turtle, mess = T:GetItemFromChest("rest", "turtle", 1, 1)
  8440.     local Disk_drive, mess = T:GetItemFromChest("rest", "computercraft:disk_drive", 1, 2, false)
  8441.     local Disk, mess = T:GetItemFromChest("rest", "computercraft:disk", 1, 3, false)
  8442.    
  8443.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  8444.    
  8445.     T:Up()
  8446.     T:Forward()
  8447.    
  8448.     for _ = 1, 2 do T:TurnRight() end
  8449.    
  8450.     T.select(1)
  8451.     T.placeDown()
  8452.    
  8453.     T:Forward()
  8454.     T:Down()
  8455.    
  8456.     for _ = 1, 2 do T:TurnRight() end
  8457.    
  8458.     local newTurtle = Per.wrap("front")
  8459.    
  8460.     local on = newTurtle.isOn()
  8461.    
  8462.     if not(on) then
  8463.        
  8464.         newTurtle.turnOn()
  8465.        
  8466.     elseif on then
  8467.        
  8468.         newTurtle.reboot()
  8469.        
  8470.     end
  8471.    
  8472.     T:Up()
  8473.     T.select(2)
  8474.     T.place()
  8475.     T.select(3)
  8476.     T.drop()
  8477.     T:Down()
  8478.    
  8479.     newTurtle = Per.wrap("front")
  8480.    
  8481.     local on = newTurtle.isOn()
  8482.    
  8483.     if not(on) then
  8484.        
  8485.         newTurtle.turnOn()
  8486.        
  8487.     elseif on then
  8488.        
  8489.         newTurtle.reboot()
  8490.        
  8491.     end
  8492.    
  8493.     sleep(5)
  8494.    
  8495.     T:Up()
  8496.     T.suck()
  8497.     T.dig()
  8498.     T:Down()
  8499.    
  8500.     newTurtle = Per.wrap("front")
  8501.    
  8502.     on = newTurtle.isOn()
  8503.    
  8504.     if on then
  8505.        
  8506.         newTurtle.shutdown()
  8507.        
  8508.     end
  8509.    
  8510.     T.dig()
  8511.    
  8512.     T:Refuel()
  8513.    
  8514.     SortStorage()
  8515.    
  8516.     GetChest()
  8517.     GetModem()
  8518.    
  8519.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  8520.     T:TurnDirection(T:getHomeR())
  8521.    
  8522. end
  8523.  
  8524.  
  8525.  
  8526. function GetBucket()
  8527.    
  8528.     T:GoTo(Chests[1])
  8529.    
  8530.     T.select(1)
  8531.    
  8532.     while T.suckDown() do end
  8533.    
  8534.     local Details = T.getItemDetail(bucketSlot)
  8535.    
  8536.     if Details and not(string.find(Details.name, "bucket")) then
  8537.        
  8538.         T.select(bucketSlot)
  8539.         T.dropDown()
  8540.        
  8541.     end
  8542.    
  8543.     Details = T.getItemDetail(chestSlot)
  8544.    
  8545.     if Details and not(string.find(Details.name, "chest")) then
  8546.        
  8547.         T.select(chestSlot)
  8548.         T.dropDown()
  8549.        
  8550.     end
  8551.    
  8552.     local chest, bucket = false, false
  8553.    
  8554.     for i = 1, 13 do
  8555.        
  8556.         Details = T.getItemDetail(i)
  8557.        
  8558.         T.select(i)
  8559.        
  8560.         if Details and string.find(Details.name, "chest") and not(chest) then
  8561.            
  8562.             T.transferTo(chestSlot, 1)
  8563.             chest = true
  8564.             T.dropDown()
  8565.            
  8566.         elseif Details and string.find(Details.name, "bucket") and not(bucket) then
  8567.            
  8568.             T.transferTo(bucketSlot, 1)
  8569.             bucket = true
  8570.             T.dropDown()
  8571.            
  8572.         else
  8573.            
  8574.             T.dropDown()
  8575.            
  8576.         end
  8577.        
  8578.     end
  8579.    
  8580.     Details = T.getItemDetail(bucketSlot)
  8581.    
  8582.     if Details and not(string.find(Details.name, "bucket")) and not(bucket) then
  8583.        
  8584.         GetChest()
  8585.         T.select(chestSlot)
  8586.         T.place()
  8587.        
  8588.         local chest1 = Per.wrap("bottom")
  8589.        
  8590.         local size1 = chest1.size()
  8591.    
  8592.         T.select(bucketSlot)
  8593.    
  8594.         for i = 1, size1 do
  8595.            
  8596.             local Details = chest1.getItemDetail(i)
  8597.            
  8598.             if Details and string.find(Details.name, "bucket") and not(bucket) then
  8599.                
  8600.                 chest1.pushItems("front", i, 1)
  8601.                 bucket = true
  8602.                
  8603.             elseif bucket then
  8604.                
  8605.                 break
  8606.                
  8607.             end
  8608.            
  8609.         end
  8610.        
  8611.         T.suck()
  8612.         T.select(chestSlot)
  8613.         T.dig()
  8614.        
  8615.     end
  8616.    
  8617.     T.select(1)
  8618.    
  8619.     T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  8620.     T:TurnDirection(T:getHomeR())
  8621.    
  8622.     if not(bucket) then
  8623.        
  8624.         MakeBucket()
  8625.         SortStorage()
  8626.         GetBucket()
  8627.        
  8628.     end
  8629.    
  8630. end
  8631.  
  8632. function GetModem()
  8633.    
  8634.     local details = T.getItemDetail(modemSlot)
  8635.    
  8636.     local findmodem = false
  8637.    
  8638.     if details and string.find(details.name, "modem") then
  8639.        
  8640.         findmodem = true
  8641.        
  8642.     else
  8643.        
  8644.         if Status > 2 then
  8645.            
  8646.             T.select(modemSlot)
  8647.             T.drop()
  8648.             T.select(1)
  8649.            
  8650.             for i = 1, 16 do
  8651.                
  8652.                 local Details = T.getItemDetail(i)
  8653.                
  8654.                 if Details then
  8655.                    
  8656.                     if string.find(Details.name, "modem") then
  8657.                        
  8658.                         T.select(i)
  8659.                         T.transferTo(modemSlot, 1)
  8660.                         findmodem = true
  8661.                        
  8662.                     end
  8663.                    
  8664.                 end
  8665.                
  8666.             end
  8667.            
  8668.             T.select(1)
  8669.            
  8670.             if not(findmodem) then
  8671.                
  8672.                 for g = 1, #Chests do
  8673.                    
  8674.                     if Chests[g].X then
  8675.                        
  8676.                         T:GoTo(Chests[g])
  8677.                        
  8678.                         GetChest()
  8679.                         T.select(chestSlot)
  8680.                        
  8681.                         local side = "front"
  8682.                        
  8683.                         if g == 9 then
  8684.                             T.placeUp()
  8685.                             side = "top"
  8686.                         else
  8687.                             T.place()
  8688.                             side = "front"
  8689.                         end
  8690.                        
  8691.                         local chest1 = Per.wrap("bottom")
  8692.                        
  8693.                         local size1 = chest1.size()
  8694.                        
  8695.                         for i = 1, size1 do
  8696.                            
  8697.                             local Details = chest1.getItemDetail(i)
  8698.                            
  8699.                             if Details then
  8700.                                
  8701.                                 if string.find(Details.name, "modem") then
  8702.                                    
  8703.                                     chest1.pushItems(side, i, 1)
  8704.                                     findmodem = true
  8705.                                     break
  8706.                                    
  8707.                                 end
  8708.                                
  8709.                             end
  8710.                            
  8711.                         end
  8712.                        
  8713.                         T.select(modemSlot)
  8714.                        
  8715.                         if g == 9 then
  8716.                             while T.suckUp() do end
  8717.                         else
  8718.                             while T.suck() do end
  8719.                         end
  8720.                        
  8721.                         T.select(chestSlot)
  8722.                        
  8723.                         if g == 9 then
  8724.                             T.digUp()
  8725.                         else
  8726.                             T.dig()
  8727.                         end
  8728.                        
  8729.                         if findmodem == true then break end
  8730.                        
  8731.                     end
  8732.                    
  8733.                 end
  8734.                
  8735.                 T.select(1)
  8736.                
  8737.                 T:GoTo(T:getHomeX(), T:getHomeY(), T:getHomeZ())
  8738.                 T:TurnDirection(T:getHomeR())
  8739.                
  8740.             end
  8741.            
  8742.         else
  8743.            
  8744.             T.select(modemSlot)
  8745.             T.drop()
  8746.             T.select(1)
  8747.            
  8748.             for i = 1, 16 do
  8749.                
  8750.                 local Details = T.getItemDetail(i)
  8751.                
  8752.                 if Details then
  8753.                    
  8754.                     if string.find(Details.name, "modem") then
  8755.                        
  8756.                         T.select(i)
  8757.                         T.transferTo(modemSlot, 1)
  8758.                         findmodem = true
  8759.                        
  8760.                     end
  8761.                    
  8762.                 end
  8763.                
  8764.             end
  8765.            
  8766.             T.select(1)
  8767.            
  8768.         end
  8769.    
  8770.     end
  8771.    
  8772.     if not(findmodem) then
  8773.         SaveFile("log", "No modem found", true)
  8774.         error()
  8775.     end
  8776.    
  8777. end
  8778.  
  8779. function GetChest()
  8780.    
  8781.     local sx,sy,sz,sr = T:getX(), T:getY(), T:getZ(), T:getR()
  8782.    
  8783.     T.select(1)
  8784.    
  8785.     local findchest = false
  8786.    
  8787.     local details = T.getItemDetail(chestSlot)
  8788.    
  8789.     if details and string.find(details.name, "chest") then
  8790.        
  8791.         findchest = true
  8792.         T.select(chestSlot)
  8793.        
  8794.     else
  8795.        
  8796.         if details and not(string.find(details.name, "chest")) then
  8797.            
  8798.             T.select(chestSlot)
  8799.             T.dropDown()
  8800.             T.select(1)
  8801.            
  8802.         end
  8803.        
  8804.         if Status > 2 and not(findchest) then
  8805.            
  8806.             for i = 1, 15 do
  8807.                
  8808.                 details = T.getItemDetail(i)
  8809.                
  8810.                 if details and string.find(details.name, "chest") then
  8811.                    
  8812.                     T.select(i)
  8813.                     T.transferTo(chestSlot,1)
  8814.                     T.select(chestSlot)
  8815.                     findchest = true
  8816.                    
  8817.                 end
  8818.                
  8819.                 if findchest == true then break end
  8820.                
  8821.             end
  8822.            
  8823.             if not(findchest) then
  8824.                
  8825.                 for g = 1, #Chests do
  8826.                    
  8827.                     if Chests[g].X then
  8828.                        
  8829.                         T:GoTo(Chests[g])
  8830.                        
  8831.                         T.select(1)
  8832.                        
  8833.                         while T.suckDown() do end
  8834.                        
  8835.                         details = T.getItemDetail(chestSlot)
  8836.                        
  8837.                         if details and not(string.find(details.name, "chest")) then
  8838.                            
  8839.                             T.select(chestSlot)
  8840.                             T.dropDown()
  8841.                             T.select(1)
  8842.                            
  8843.                         end
  8844.                        
  8845.                         for i = 1, 15 do
  8846.                            
  8847.                             details = T.getItemDetail(i)
  8848.                            
  8849.                             if details and string.find(details.name, "chest") then
  8850.                                
  8851.                                 T.select(i)
  8852.                                 T.transferTo(chestSlot,1)
  8853.                                 T.select(chestSlot)
  8854.                                 findchest = true
  8855.                                
  8856.                             elseif details then
  8857.                                
  8858.                                 T.select(i)
  8859.                                 T.dropDown()
  8860.                                
  8861.                             end
  8862.                            
  8863.                         end
  8864.                        
  8865.                         T.select(chestSlot)
  8866.                        
  8867.                         if findchest == true then break end
  8868.                        
  8869.                     end
  8870.                    
  8871.                 end
  8872.                
  8873.                 T:GoTo(sx, sy, sz)
  8874.                 T:TurnDirection(sr)
  8875.                
  8876.             end
  8877.            
  8878.         elseif not(findchest) then
  8879.            
  8880.             details = T.getItemDetail(chestSlot)
  8881.            
  8882.             if details and not(string.find(details.name, "chest")) then
  8883.                
  8884.                 T.select(chestSlot)
  8885.                 T.dropDown()
  8886.                 T.select(1)
  8887.                
  8888.             end
  8889.            
  8890.             for i = 1, 15 do
  8891.                
  8892.                 details = T.getItemDetail(i)
  8893.                
  8894.                 if details and string.find(details.name, "chest") then
  8895.                    
  8896.                     T.select(i)
  8897.                     T.transferTo(chestSlot,1)
  8898.                     T.select(chestSlot)
  8899.                     findchest = true
  8900.                    
  8901.                 elseif details then
  8902.                    
  8903.                     T.select(i)
  8904.                     T.dropDown()
  8905.                    
  8906.                 end
  8907.                
  8908.                 T.select(chestSlot)
  8909.                
  8910.                 if findchest == true then break end
  8911.                
  8912.             end
  8913.            
  8914.         end
  8915.    
  8916.     end
  8917.    
  8918.     if not(findchest) then
  8919.         SaveFile("log", "No chest found", true)
  8920.         error()
  8921.     end
  8922.    
  8923. end
  8924.  
  8925.  
  8926. if T.getFuelLevel() < 500 and Status > 5 then
  8927.     T:Refuel()
  8928. elseif T.getFuelLevel() < 500 and Status <= 5 then
  8929.    
  8930.     local succes, Succes = {}, false
  8931.    
  8932.     for i = 1, 13 do
  8933.         T.select(i)
  8934.         table.insert(succes, T.refuel())
  8935.     end
  8936.    
  8937.     T.select(1)
  8938.    
  8939.     for i = 1, succes do
  8940.         if succes[i] then
  8941.             Succes = true
  8942.         end
  8943.     end
  8944.    
  8945.     while not(Succes) do
  8946.        
  8947.         local succes1, details = T.inspect()
  8948.        
  8949.         succes = {}
  8950.        
  8951.         if succes1 then
  8952.             if string.find(details.name, "log") then
  8953.                 T.dig()
  8954.                 table.insert(succes, T.refuel())
  8955.             else
  8956.                 print("X")
  8957.                 SaveFile("log", "Cant refuel", true)
  8958.                 error()
  8959.             end
  8960.         else
  8961.             print("X")
  8962.             SaveFile("log", "Cant refuel", true)
  8963.             error()
  8964.         end
  8965.        
  8966.         for i = 1, succes do
  8967.             if succes[i] then
  8968.                 Succes = true
  8969.             end
  8970.         end
  8971.     end
  8972.    
  8973. end
  8974.  
  8975. if T:getX() ~= T:getHomeX() or T:getY() ~= T:getHomeY() or T:getZ() ~= T:getHomeZ() or T:getR() ~= T:getHomeR() then
  8976.     -- gohome
  8977.     if T.getFuelLevel() < 500 and Status > 5 then
  8978.         T:Refuel()
  8979.     elseif T.getFuelLevel() < 500 and Status <= 5 then
  8980.        
  8981.         local succes, Succes = {}, false
  8982.        
  8983.         for i = 1, 13 do
  8984.             T.select(i)
  8985.             table.insert(succes, T.refuel())
  8986.         end
  8987.        
  8988.         T.select(1)
  8989.        
  8990.         for i = 1, succes do
  8991.             if succes[i] then
  8992.                 Succes = true
  8993.             end
  8994.         end
  8995.        
  8996.         while not(Succes) do
  8997.            
  8998.             local succes1, details = T.inspect()
  8999.            
  9000.             succes = {}
  9001.            
  9002.             if succes1 then
  9003.                 if string.find(details.name, "log") then
  9004.                     T.dig()
  9005.                     table.insert(succes, T.refuel())
  9006.                 else
  9007.                     print("X")
  9008.                     SaveFile("log", "Cant refuel", true)
  9009.                     error()
  9010.                 end
  9011.             else
  9012.                 print("X")
  9013.                 SaveFile("log", "Cant refuel", true)
  9014.                 error()
  9015.             end
  9016.            
  9017.             for i = 1, succes do
  9018.                 if succes[i] then
  9019.                     Succes = true
  9020.                 end
  9021.             end
  9022.         end
  9023.        
  9024.     end
  9025.     T:GoHome()
  9026. end
  9027.  
  9028. Monitor[0].write("Want to load from Status "..Status.."? Y/N: ")
  9029.  
  9030. local event, Answer, p2 = System.pullEvent("key")
  9031.  
  9032. if Answer == keys.n then
  9033.     print("N")
  9034.     SaveFile("log", "Want to load from Status "..Status.."? Y/N: N", false)
  9035.     SaveFile("log", "Get a  Total Reset: ", true)
  9036.     local file = fs.exists("/HomeCor.txt")
  9037.     if file then fs.delete("/.HomeCor.txt") end
  9038.     file = fs.exists("/.Locations.lo")
  9039.     if file then fs.delete("/.Locations.lo") end
  9040.     file = fs.exists("/.Chests.ch")
  9041.     if file then fs.delete("/.Chests.ch") end
  9042.     file = fs.exists("/.Status.st")
  9043.     if file then fs.delete("/.Status.st") end
  9044.     System.reboot()
  9045. else
  9046.     print("Y")
  9047.     SaveFile("log", "Want to load from Status "..Status.."? Y/N: Y", false)
  9048. end
  9049.  
  9050. file = fs.exists("/.Locations.lo")
  9051.  
  9052. if file then
  9053.    
  9054.     SaveFile("log", "Loading Locations", true)
  9055.    
  9056.     file = fs.open("/.Locations.lo", "r")
  9057.     local Data = UnPack(file.readAll())
  9058.     file.close()
  9059.    
  9060.     if Data.Water then
  9061.         Water = Data.Water
  9062.     end
  9063.    
  9064.     if Data.Sand then
  9065.         Sand = Data.Sand
  9066.     end
  9067.    
  9068.     if Data.Mine then
  9069.         Mine = Data.Mine
  9070.     end
  9071.    
  9072.     if Data.Lava then
  9073.         T:setLava(Data.Lava)
  9074.     end
  9075.    
  9076.     SaveFile("log", "Loaded Locations", true)
  9077.    
  9078. end
  9079.  
  9080. file = fs.exists("/.Chests.ch")
  9081.  
  9082. if file then
  9083.    
  9084.     SaveFile("log", "Loading chests", true)
  9085.    
  9086.     file = fs.open("/.Chests.ch", "r")
  9087.     local Data = UnPack(file.readAll())
  9088.     file.close()
  9089.    
  9090.     Chests = Data
  9091.     SaveFile("log", "Loaded chests", true)
  9092.    
  9093. end
  9094.  
  9095. if Status > 2 then
  9096.    
  9097.     SaveFile("log", "Looking for Tool: "..Tools[3], true)
  9098.    
  9099.     for i = 1, 2 do
  9100.         T:Forward()
  9101.     end
  9102.    
  9103.     T.select(13)
  9104.     Toolequip()
  9105.     T.select(1)
  9106.    
  9107.     while T.suckDown() do end
  9108.    
  9109.     EquipRight = false
  9110.    
  9111.     for i = 1, 16 do
  9112.        
  9113.         local details = T.getItemDetail(i)
  9114.        
  9115.         if details then
  9116.            
  9117.             for _, name in ipairs(Tools) do
  9118.                
  9119.                 if details.name == name then
  9120.                    
  9121.                     if details.name == Tools[3] then
  9122.                        
  9123.                         T.select(i)
  9124.                         EquipRight = Toolequip()
  9125.                        
  9126.                     end
  9127.                    
  9128.                 end
  9129.                
  9130.             end
  9131.            
  9132.         end
  9133.        
  9134.     end
  9135.    
  9136.     for i = 1, 16 do
  9137.         if T.getItemDetail(i) ~= nil and not(string.find(T.getItemDetail(i).name, "chest")) then
  9138.             T.select(i)
  9139.             T.dropDown()
  9140.         end
  9141.     end
  9142.    
  9143.     for i = 1, 15 do
  9144.         if T.getItemDetail(i) ~= nil and string.find(T.getItemDetail(i).name, "chest") then
  9145.             T.select(i)
  9146.             T.transferTo(chestSlot, 1)
  9147.         end
  9148.     end
  9149.    
  9150.     for i = 1, 15 do
  9151.         T.select(i)
  9152.         T.dropDown()
  9153.     end
  9154.    
  9155.     for i = 1, 2 do
  9156.         T:Back()
  9157.     end
  9158.    
  9159.     GetModem()
  9160.    
  9161.     if not(EquipRight)then
  9162.        
  9163.         Monitor[0].clear()
  9164.         Monitor[0].setCursorPos(1, 1)
  9165.        
  9166.         SaveFile("log", "Tool not found : "..Tools[3], true)
  9167.        
  9168.         error()
  9169.        
  9170.     end
  9171.  
  9172. end
  9173.  
  9174. T.select(1)
  9175.  
  9176. if Status >= 6 then
  9177.    
  9178.     SortStorage(0)
  9179.    
  9180.     if T.getFuelLevel() < 500 then
  9181.        
  9182.         T:Refuel()
  9183.        
  9184.     end
  9185.    
  9186.     GetModem()
  9187.    
  9188. end
  9189.  
  9190.  
  9191. function Main()
  9192.  
  9193.     if Status == 1 then
  9194.         FirstTree()
  9195.     end
  9196.    
  9197.     if Status == 2 then
  9198.         MakeChest()
  9199.     end
  9200.    
  9201.     if Status == 3 then
  9202.         HarvestAllTrees()
  9203.     end
  9204.    
  9205.     if Status == 4 then
  9206.         GetCobbleStone()
  9207.     end
  9208.    
  9209.     if Status == 5 then
  9210.         MakeStorage()
  9211.     end
  9212.    
  9213.     if Status == 6 then
  9214.        
  9215.         T:Refuel()
  9216.         GetModem()
  9217.         Makefurnace()
  9218.         MakeBucket()
  9219.         MakeSaplingChest()
  9220.        
  9221.     end
  9222.    
  9223.     if Status == 7 then
  9224.        
  9225.         T:Refuel()
  9226.         SortStorage()
  9227.         GetModem()
  9228.         T.select(1)
  9229.         MakeHopper()
  9230.         MakeTorches()
  9231.         T:emptyInv()
  9232.         SortStorage()
  9233.         T:Refuel()     
  9234.         GetBucket()
  9235.         MakeTreeFarm()
  9236.         SortStorage()
  9237.        
  9238.     end
  9239.    
  9240.     if Status == 8 then
  9241.        
  9242.         T:Refuel()
  9243.         GoMine(1)
  9244.        
  9245.     end
  9246.    
  9247.     if Status == 9 then
  9248.        
  9249.         T:Refuel()
  9250.         GoMine(2)
  9251.        
  9252.     end
  9253.    
  9254.     if Status == 10 then
  9255.        
  9256.         T:Refuel()
  9257.         GoMine(3)
  9258.        
  9259.         if T:getLava() then
  9260.             MakeGenerate()
  9261.         end
  9262.        
  9263.         Status = 11
  9264.        
  9265.         SaveFile("status")
  9266.        
  9267.     end
  9268.    
  9269.     if Status == 11 then
  9270.        
  9271.         T:Refuel()
  9272.         FixMine(1)
  9273.        
  9274.     end
  9275.    
  9276.     if Status == 12 then
  9277.        
  9278.         T:Refuel()
  9279.         FixMine(2)
  9280.        
  9281.     end
  9282.    
  9283.     if Status == 13 then
  9284.        
  9285.         T:Refuel()
  9286.         FixMine(3)
  9287.        
  9288.     end
  9289.    
  9290.     if Status == 14 then
  9291.        
  9292.         T:Refuel()
  9293.         MakeSword()
  9294.        
  9295.     end
  9296.    
  9297.     if Status == 15 then
  9298.        
  9299.         T:Refuel()
  9300.         T:GetItemFromChest("rest", "ender_pearl", 64, 3)
  9301.         AttackMobs(2)
  9302.         T:GetItemFromChest("sapling", "bone", 64, 3)
  9303.         AttackMobs()
  9304.        
  9305.     end
  9306.    
  9307.     if Status == 16 then
  9308.        
  9309.         T:Refuel()
  9310.         MinetoBedRock()
  9311.        
  9312.     end
  9313.    
  9314.     if Status == 17 then
  9315.        
  9316.         T:Refuel()
  9317.         PlaceLadder()
  9318.        
  9319.     end
  9320.    
  9321.     if Status == 18 then
  9322.        
  9323.         T:Refuel()
  9324.         MakeShaft()
  9325.        
  9326.     end
  9327.    
  9328.     if Status == 19 then
  9329.        
  9330.         T:Refuel()
  9331.         CraftDiskDive()
  9332.        
  9333.     end
  9334.    
  9335.     if Status == 20 then
  9336.        
  9337.         CraftTurtle()
  9338.         ProgramTurtle()
  9339.        
  9340.     end
  9341.    
  9342. end
  9343.  
  9344. Main()
Add Comment
Please, Sign In to add comment