MarcosKoco

TRC_Turtle

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