MarcosKoco

TRC_Computer

Jun 5th, 2021 (edited)
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 159.38 KB | None | 0 0
  1. -- Turtle Remote Controle Computer
  2.  
  3. -- Minecraft 1.16.5
  4. -- Forge 36.1.66
  5. -- Mod: cc-tweaked-1.16.4-1.96.0.jar
  6.  
  7. local Version = "1.0.6"
  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 Monitor = {}
  17.  
  18. Monitor[0] = Screen -- sets Monitor[0] to term
  19.  
  20. local file = fs.exists("/API/Logo.lua")
  21.  
  22. if not(file) then
  23.  
  24.     shell.run("pastebin get s3aBGUVr /API/Logo.lua")
  25.    
  26.     Monitor[0].clear()
  27.     Monitor[0].setCursorPos(1,1)
  28.    
  29. end
  30.  
  31. System.loadAPI("/API/Logo.lua")
  32.  
  33. local w, h = Monitor[0].getSize()
  34.  
  35. Monitor[0].clear()
  36.  
  37. Logo.drawLogo(Monitor[0], "Head", math.floor(w/2)-6, math.floor(h/2)-4)
  38.  
  39. Monitor[0].setCursorPos(1, (h-1))
  40. Monitor[0].clearLine()
  41. Monitor[0].setBackgroundColor(colors.white)
  42. Monitor[0].setTextColor(colors.black)
  43. Monitor[0].setCursorPos(math.floor((w - string.len("Looking for file...")) /2), (h-1))
  44.  
  45. print("Looking for files...")
  46.  
  47. local file0 = fs.exists("/API/Functions.lua")
  48. local file1 = fs.exists("/API/Button.lua")
  49. local file2 = fs.exists("/API/MonButton.lua")
  50.  
  51. Monitor[0].setBackgroundColor(colors.black)
  52. Monitor[0].setTextColor(colors.white)
  53.  
  54. sleep(1)
  55.  
  56. if not(file0) then
  57.    
  58.     Monitor[0].setCursorPos(1, (h-1))
  59.     Monitor[0].clearLine()
  60.     Monitor[0].setBackgroundColor(colors.white)
  61.     Monitor[0].setTextColor(colors.black)
  62.     Monitor[0].setCursorPos(math.floor((w - string.len("Downloading Function file...")) /2), (h-1))
  63.  
  64.     print("Downloading Function file...")
  65.    
  66.     shell.run("pastebin get sujHjqXC /API/Functions.lua")
  67.    
  68.     Monitor[0].setBackgroundColor(colors.black)
  69.     Monitor[0].setTextColor(colors.white)
  70.    
  71.     sleep(1)
  72.    
  73. end
  74.  
  75. if not(file1) then
  76.    
  77.     Monitor[0].setCursorPos(1, (h-1))
  78.     Monitor[0].clearLine()
  79.     Monitor[0].setBackgroundColor(colors.white)
  80.     Monitor[0].setTextColor(colors.black)
  81.     Monitor[0].setCursorPos(math.floor((w - string.len("Downloading Button file...")) /2), (h-1))
  82.  
  83.     print("Downloading Button file...")
  84.    
  85.     shell.run("pastebin get mKpxpWmZ /API/Button.lua")
  86.    
  87.     Monitor[0].setBackgroundColor(colors.black)
  88.     Monitor[0].setTextColor(colors.white)
  89.    
  90.     sleep(1)
  91.    
  92. end
  93.  
  94. if not(file2) then
  95.    
  96.     Monitor[0].setCursorPos(1, (h-1))
  97.     Monitor[0].clearLine()
  98.     Monitor[0].setBackgroundColor(colors.white)
  99.     Monitor[0].setTextColor(colors.black)
  100.     Monitor[0].setCursorPos(math.floor((w - string.len("Downloading Monitor Button file...")) /2), (h-1))
  101.  
  102.     print("Downloading Monitor Button file...")
  103.    
  104.     shell.run("pastebin get mKpxpWmZ /API/MonButton.lua")
  105.    
  106.     Monitor[0].setBackgroundColor(colors.black)
  107.     Monitor[0].setTextColor(colors.white)
  108.    
  109.     sleep(1)
  110.    
  111. end
  112.  
  113. Monitor[0].clear()
  114.  
  115. Logo.drawLogo(Monitor[0], "Head", math.floor(w/2)-6, math.floor(h/2)-4)
  116.  
  117. Monitor[0].setCursorPos(1, (h-1))
  118. Monitor[0].clearLine()
  119. Monitor[0].setBackgroundColor(colors.white)
  120. Monitor[0].setTextColor(colors.black)
  121. Monitor[0].setCursorPos(math.floor((w - string.len("Installing files...")) /2), (h-1))
  122.  
  123. print("Installing files...")
  124.  
  125. System.loadAPI("/API/Functions.lua")
  126. System.loadAPI("/API/Button.lua")
  127. System.loadAPI("/API/MonButton.lua")
  128.  
  129. Button.setMonitor(false)
  130.  
  131. Functions.SetColors(Monitor[0], colors.black, colors.white)
  132.  
  133. sleep(1)
  134.  
  135. Monitor[0].setCursorPos(1, (h-1))
  136. Monitor[0].clearLine()
  137.  
  138. local Disk = Functions.FindDisk()
  139.  
  140. sleep(1)
  141.  
  142. if Disk then
  143.    
  144.     Monitor[0].setCursorPos(1, (h-1))
  145.     Monitor[0].clearLine()
  146.     Functions.SetColors(Monitor[0], colors.white, colors.black)
  147.     Monitor[0].setCursorPos(math.floor((w - string.len("Installing Disk...")) /2), (h-1))
  148.    
  149.     print("Installing Disk...")
  150.    
  151.     Disk = Per.wrap(Disk)
  152.    
  153.     Functions.SetColors(Monitor[0], colors.black, colors.white)
  154.    
  155.     sleep(1)
  156.    
  157. end
  158.  
  159. Monitor[0].setCursorPos(1, (h-1))
  160. Monitor[0].clearLine()
  161.  
  162. local Modem = Functions.FindModem()
  163.  
  164. sleep(1)
  165.  
  166. if Modem then
  167.    
  168.     Monitor[0].setCursorPos(1, (h-1))
  169.     Monitor[0].clearLine()
  170.     Functions.SetColors(Monitor[0], colors.white, colors.black)
  171.     Monitor[0].setCursorPos(math.floor((w - string.len("Installing Modem...")) /2), (h-1))
  172.    
  173.     print("Installing Modem...")
  174.    
  175.     Modem = Per.wrap(Modem)
  176.    
  177.     Modem.Send = Modem.transmit
  178.     Modem.closeAll()
  179.    
  180.     Functions.SetColors(Monitor[0], colors.black, colors.white)
  181.    
  182.     sleep(1)
  183.    
  184. end
  185.  
  186. Monitor[0].setCursorPos(1, (h-1))
  187. Monitor[0].clearLine()
  188.  
  189. local WModem = Functions.FindWirelessModem()
  190.  
  191. sleep(1)
  192.  
  193. if WModem then
  194.    
  195.     Monitor[0].setCursorPos(1, (h-1))
  196.     Monitor[0].clearLine()
  197.     Functions.SetColors(Monitor[0], colors.white, colors.black)
  198.     Monitor[0].setCursorPos(math.floor((w - string.len("Installing Wireless Modem...")) /2), (h-1))
  199.  
  200.     print("Installing Wireless Modem...")
  201.    
  202.     WModem = Per.wrap(WModem)
  203.    
  204.     WModem.Send = WModem.transmit
  205.     WModem.closeAll()
  206.    
  207.     Functions.SetColors(Monitor[0], colors.black, colors.white)
  208.    
  209.     sleep(1)
  210.    
  211. end
  212.  
  213. Monitor[0].setCursorPos(1, (h-1))
  214. Monitor[0].clearLine()
  215.  
  216. Monitor[1] = Functions.FindMonitor()
  217.  
  218. sleep(1)
  219.  
  220. if Monitor[1] then
  221.    
  222.     Monitor[0].setCursorPos(1, (h-1))
  223.     Monitor[0].clearLine()
  224.     Functions.SetColors(Monitor[0], colors.white, colors.black)
  225.     Monitor[0].setCursorPos(math.floor((w - string.len("Installing Monitor...")) /2), (h-1))
  226.  
  227.     print("Installing Monitor...")
  228.    
  229.     Monitor[1] = Per.wrap(Monitor[1])
  230.    
  231.     MonButton.setMonitor(true)
  232.    
  233.     Functions.SetColors(Monitor[0], colors.black, colors.white)
  234.    
  235.     local mw, mh = Monitor[1].getSize()
  236.    
  237.     Logo.drawLogo(Monitor[1], "Head", math.floor(mw/2)-6, math.floor(mh/2)-3)
  238.    
  239.     sleep(1)
  240.    
  241. end
  242.  
  243. Monitor[0].setCursorPos(1, (h-1))
  244. Monitor[0].clearLine()
  245.  
  246. local Printer = Functions.FindPrinter()
  247.  
  248. sleep(1)
  249.  
  250. if Printer then
  251.    
  252.     Monitor[0].setCursorPos(1, (h-1))
  253.     Monitor[0].clearLine()
  254.     Functions.SetColors(Monitor[0], colors.white, colors.black)
  255.     Monitor[0].setCursorPos(math.floor((w - string.len("Installing Printer...")) /2), (h-1))
  256.  
  257.     print("Installing Printer...")
  258.    
  259.     Printer = Per.wrap(Printer)
  260.    
  261.     Functions.SetColors(Monitor[0], colors.black, colors.white)
  262.    
  263.     sleep(1)
  264.    
  265. end
  266.  
  267. Monitor[0].setCursorPos(1, (h-1))
  268. Monitor[0].clearLine()
  269.  
  270. local Speaker = Functions.FindSpeaker()
  271.  
  272. sleep(1)
  273.  
  274. if Speaker then
  275.    
  276.     Monitor[0].setCursorPos(1, (h-1))
  277.     Monitor[0].clearLine()
  278.     Functions.SetColors(Monitor[0], colors.white, colors.black)
  279.     Monitor[0].setCursorPos(math.floor((w - string.len("Installing Speaker...")) /2), (h-1))
  280.  
  281.     print("Installing Speaker...")
  282.    
  283.     Speaker = Per.wrap(Speaker)
  284.    
  285.     Functions.SetColors(Monitor[0], colors.black, colors.white)
  286.    
  287.     sleep(1)
  288.    
  289. end
  290.  
  291. Monitor[0].setCursorPos(1, (h-1))
  292. Monitor[0].clearLine()
  293.  
  294.  
  295. Monitor[0].setCursorPos(1, (h-1))
  296. Monitor[0].clearLine()
  297. Functions.SetColors(Monitor[0], colors.white, colors.black)
  298. Monitor[0].setCursorPos(math.floor((w - string.len("Done")) /2), (h-1))
  299.  
  300. print("Done")
  301.  
  302. Functions.SetColors(Monitor[0], colors.black, colors.white)
  303.  
  304. sleep(1)
  305.  
  306.  
  307. local Computer = { System = {ComputerName = "R_Controle_Turtles ",
  308.                             OldComputerName = System.getComputerLabel(),
  309.                             Status = true,
  310.                             LogOn = false,
  311.                             Modem = {ServerID = 0,
  312.                                     SharedID = 0,
  313.                                     OwnID = 1000,
  314.                                     foundWireless = false
  315.                                     },
  316.                             First = true,
  317.                             Nether = false,
  318.                             StateMonitor = false
  319.                             },
  320.                 Connection = {Connected = false,
  321.                             ConnectedID = 0,
  322.                             ConnectedTurtle = {}
  323.                             }
  324.                 }
  325.  
  326. local Turtles = {}
  327. local TreeFarms = {}
  328. local OverworldFarms = {}
  329. local NetherFarms = {}
  330. local TravelHeight = 250
  331.  
  332. local Color = { Green = colors.green,
  333.                 Red = colors.red,
  334.                 Black = colors.black,
  335.                 White = colors.white,
  336.                 Orange = colors.orange,
  337.                 Magenta = colors.magenta,
  338.                 LightBlue = colors.lightBlue,
  339.                 Yellow = colors.yellow,
  340.                 Lime = colors.lime,
  341.                 Pink = colors.pink,
  342.                 Gray = colors.gray,
  343.                 LightGray = colors.lightGray,
  344.                 Cyan = colors.cyan,
  345.                 Purple = colors.purple,
  346.                 Blue = colors.blue,
  347.                 Brown = colors.brown,
  348.                 }
  349.  
  350. local Temp = {}
  351.  
  352. local Timer = {}
  353.  
  354. local Tool = {
  355.             PickAxe = "minecraft:diamond_pickaxe",
  356.             Shovel = "minecraft:diamond_shovel",
  357.             Axe = "minecraft:diamond_axe",
  358.             Hoe = "minecraft:diamond_hoe",
  359.             Sword = "minecraft:diamond_sword"
  360.             }
  361.  
  362. local GoToX, GoToY, GoToZ, Radius, Layer = 0, 0, 0, 3, 6
  363. local MinRadius = 3
  364. local MaxRadius = 129
  365. local FreeGroupT = {}
  366. local Enter
  367. local Number
  368.  
  369. local ButtonForward
  370. local ButtonBack
  371. local ButtonLeft
  372. local ButtonRight
  373. local ButtonUp
  374. local ButtonDown
  375.  
  376. local Sec = 1
  377. local Min = Sec * 60
  378. local HalfHour = Min * 30
  379. local Hour = HalfHour * 2
  380.  
  381. local w, h = Screen.getSize()
  382. local NameLen = 17
  383.  
  384. local nMonitorOption = 0
  385. local nMonitorTurtleInventoryOption = 0
  386.  
  387. local nOption = 1
  388. local nSystemOption = 1
  389. local nTurtlesOption = 1
  390. local nTurtleInfoOption = 1
  391. local nTurtleSystemOption = 1
  392. local nTurtleEquipOption = 1
  393. local nTurtleDetectOption = 1
  394. local mTurtleInspectOption = 1
  395. local nTurtleCompareOption = 1
  396. local nTurtleMovementsOption = 1
  397. local nTurtleAttackOption = 1
  398. local nTurtleDigOption = 1
  399. local nTurtleSuckOption = 1
  400. local nTurtleDropOption = 1
  401. local nTurtlePlaceOption = 1
  402. local nTurtleProgramsOption = 1
  403.  
  404. local MaxOptions = 5
  405. local MaxSystemOptions = 4
  406. local MaxTurtlesOptions
  407. local MaxTurtleInfoOptions = 2
  408. local MaxTurtleSystemOptions = 13
  409. local MaxTurtleEquipOptions = 2
  410. local MaxTurtleDetectOptions = 3
  411. local MaxTurtleInspectOptions = 3
  412. local MaxTurtleCompareOptions = 3
  413. local MaxTurtleMovementsOptions = 9
  414. local MaxTurtleAttackOptions = 3
  415. local MaxTurtleDigOptions = 3
  416. local MaxTurtleSuckOptions = 3
  417. local MaxTurtleDropOptions = 3
  418. local MaxTurtlePlaceOptions = 3
  419. local MaxTurtleProgramsOptions = 5
  420.  
  421.  
  422. Temp.FarmTimer = Hour * 2
  423.  
  424. System.setComputerLabel(Computer.System.ComputerName)
  425.  
  426. function HadError(Mess)
  427.    
  428.     print(Mess)
  429.     Function.SetColors(Monitor[0], Color.Black, Color.White)
  430.     Monitor[0].setCursorPos(1, h)
  431.     error()
  432.    
  433. end
  434.  
  435. local InventoryButton = {}
  436.  
  437. function ConfigInventoryBottons()
  438.    
  439.     local mx, my = Monitor[1].getSize()
  440.    
  441.     local BottomMonitor = my - 1
  442.     local TopMonitor = 1 + 1
  443.     local EndMonitor = mx + 1
  444.     local BeginMonitor = 1 + 1
  445.    
  446.     -- Inventory Buttons on monitor
  447.    
  448.     MINVButton.clearButtons()
  449.    
  450.     for i = 1, 16 do
  451.        
  452.         InventoryButton[i] = false
  453.        
  454.     end
  455.    
  456.     MINVButton.setButton("1", ClickedInventoryButton, BeginMonitor, BeginMonitor + 4, TopMonitor + 3, TopMonitor + 5, true, "1")
  457.     MINVButton.setButton("2", ClickedInventoryButton, BeginMonitor + 6, BeginMonitor + 10, TopMonitor + 3, TopMonitor + 5, true, "2")
  458.     MINVButton.setButton("3", ClickedInventoryButton, BeginMonitor + 12, BeginMonitor + 16, TopMonitor + 3, TopMonitor + 5, true, "3")
  459.     MINVButton.setButton("4", ClickedInventoryButton, BeginMonitor + 18, BeginMonitor + 22, TopMonitor + 3, TopMonitor + 5, true, "4")
  460.     MINVButton.setButton("5", ClickedInventoryButton, BeginMonitor, BeginMonitor + 4, TopMonitor + 7, TopMonitor + 9, true, "5")
  461.     MINVButton.setButton("6", ClickedInventoryButton, BeginMonitor + 6, BeginMonitor + 10, TopMonitor + 7, TopMonitor + 9, true, "6")
  462.     MINVButton.setButton("7", ClickedInventoryButton, BeginMonitor + 12, BeginMonitor + 16, TopMonitor + 7, TopMonitor + 9, true, "7")
  463.     MINVButton.setButton("8", ClickedInventoryButton, BeginMonitor + 18, BeginMonitor + 22, TopMonitor + 7, TopMonitor + 9, true, "8")
  464.     MINVButton.setButton("9", ClickedInventoryButton, BeginMonitor, BeginMonitor + 4, TopMonitor + 11, TopMonitor + 13, true, "9")
  465.     MINVButton.setButton("10", ClickedInventoryButton, BeginMonitor + 6, BeginMonitor + 10, TopMonitor + 11, TopMonitor + 13, true, "10")
  466.     MINVButton.setButton("11", ClickedInventoryButton, BeginMonitor + 12, BeginMonitor + 16, TopMonitor + 11, TopMonitor + 13, true, "11")
  467.     MINVButton.setButton("12", ClickedInventoryButton, BeginMonitor + 18, BeginMonitor + 22, TopMonitor + 11, TopMonitor + 13, true, "12")
  468.     MINVButton.setButton("13", ClickedInventoryButton, BeginMonitor, BeginMonitor + 4, TopMonitor + 15, TopMonitor + 17, true, "13")
  469.     MINVButton.setButton("14", ClickedInventoryButton, BeginMonitor + 6, BeginMonitor + 10, TopMonitor + 15, TopMonitor + 17, true, "14")
  470.     MINVButton.setButton("15", ClickedInventoryButton, BeginMonitor + 12, BeginMonitor + 16, TopMonitor + 15, TopMonitor + 17, true, "15")
  471.     MINVButton.setButton("16", ClickedInventoryButton, BeginMonitor + 18, BeginMonitor + 22, TopMonitor + 15, TopMonitor + 17, true, "16")
  472.     MINVButton.setButton("Refuel", Do, BeginMonitor + 24, BeginMonitor + 33, TopMonitor + 3, TopMonitor + 5, true, "Fuel")
  473.     MINVButton.setButton("Empty", Do, BeginMonitor + 24, BeginMonitor + 33, TopMonitor + 7, TopMonitor + 9, true, "EmptyInventory")
  474.    
  475.     MINVButton.setButton("Slot", Do, BeginMonitor + 35, BeginMonitor + 40, TopMonitor + 5, TopMonitor + 7, false, "EmptyInventorySlot")
  476.     MINVButton.setButton("All", Do, BeginMonitor + 35, BeginMonitor + 40, TopMonitor + 9, TopMonitor + 11, false, "EmptyInventoryAll")
  477.    
  478.     MINVButton.setButton("Equip", Do, BeginMonitor + 24, BeginMonitor + 33, TopMonitor + 11, TopMonitor + 13, true, "EquipLeft")
  479.     MINVButton.setButton("Transfer", Do, BeginMonitor + 24, BeginMonitor + 33, TopMonitor + 15, TopMonitor + 17, true, "Transfer")
  480.    
  481.     if nMonitorTurtleInventoryOption == 0 then
  482.        
  483.         nMonitorTurtleInventoryOption = Computer.Connection.ConnectedTurtle.SlotSelected
  484.         InventoryButton[nMonitorTurtleInventoryOption] = true
  485.         MINVButton.toggleButton(tostring(nMonitorTurtleInventoryOption))
  486.        
  487.     end
  488.    
  489. end
  490.  
  491. local MButtonn = false
  492. local ButtonInfo = false
  493. local ButtonInventory = false
  494. local ButtonQuarry2 = false
  495.  
  496. function ConfigMonitor()
  497.    
  498.     local mx, my = Monitor[1].getSize()
  499.    
  500.     local BottomMonitor = my - 1
  501.     local TopMonitor = 1 + 1
  502.     local EndMonitor = mx + 1
  503.     local BeginMonitor = 1 + 1
  504.    
  505.     MMenuButton.clearButtons()
  506.     MMoveButton.clearButtons()
  507.     MStripMineButton.clearButtons()
  508.    
  509.     -- Menu Buttons on monitor
  510.    
  511.     MMenuButton.setButton("M", MoveMentOption, BeginMonitor + 3, BeginMonitor + 5, BottomMonitor - 9, BottomMonitor - 7, true)
  512.     MMenuButton.setButton("Info", TurtleInfo, BeginMonitor - 1, BeginMonitor + 4, TopMonitor - 1, TopMonitor + 1, true)
  513.     MMenuButton.setButton("Inventory", InventoryInfo, BeginMonitor + 5, BeginMonitor + 16, TopMonitor - 1, TopMonitor + 1, true)
  514.     MMenuButton.setButton("Strip Mine", Quarry2, BeginMonitor + 17, BeginMonitor + 28, TopMonitor - 1, TopMonitor + 1, true)
  515.    
  516.    
  517.     -- Strip Mine Buttons on monitor
  518.            
  519.     local ButtonMinStart = 16
  520.     local ButtonPlusStart = 36
  521.     local ButtonEditStart = 48
  522.     local ButtonLength = 10
  523.     local ButtonHeight = 2
  524.    
  525.     MStripMineButton.setButton("- X", Quarry, ButtonMinStart, ButtonMinStart + ButtonLength, 5, 5 + ButtonHeight, true, "XMin")
  526.     MStripMineButton.setButton("+ X", Quarry, ButtonPlusStart, ButtonPlusStart + ButtonLength, 5, 5 + ButtonHeight, true, "XPlus")
  527.     MStripMineButton.setButton("E X", Edit, ButtonEditStart, ButtonEditStart + ButtonLength, 5, 5 + ButtonHeight, true, "XEdit")
  528.    
  529.     MStripMineButton.setButton("- Z", Quarry, ButtonMinStart, ButtonMinStart + ButtonLength, 5 + 3, (5 + 3) + ButtonHeight, true, "ZMin")
  530.     MStripMineButton.setButton("+ Z", Quarry, ButtonPlusStart, ButtonPlusStart + ButtonLength, 5 + 3, (5 + 3) + ButtonHeight, true, "ZPlus")
  531.     MStripMineButton.setButton("E Z", Edit, ButtonEditStart, ButtonEditStart + ButtonLength, 5 + 3, (5 + 3) + ButtonHeight, true, "ZEdit")
  532.    
  533.     MStripMineButton.setButton("- Layer", Quarry, ButtonMinStart, ButtonMinStart + ButtonLength, 5 + 7, (5 + 7) + ButtonHeight, true, "LayerMin")
  534.     MStripMineButton.setButton("+ Layer", Quarry, ButtonPlusStart, ButtonPlusStart + ButtonLength, 5 + 7, (5 + 7) + ButtonHeight, true, "LayerPlus")
  535.     MStripMineButton.setButton("E Layer", Edit, ButtonEditStart, ButtonEditStart + ButtonLength, 5 + 7, (5 + 7) + ButtonHeight, true, "LayerEdit")
  536.    
  537.     MStripMineButton.setButton("- Radius", Quarry, ButtonMinStart, ButtonMinStart + ButtonLength, 5 + 11, (5 + 11) + ButtonHeight, true, "RadiusMin")
  538.     MStripMineButton.setButton("+ Radius", Quarry, ButtonPlusStart, ButtonPlusStart + ButtonLength, 5 + 11, (5 + 11) + ButtonHeight, true, "RadiusPlus")
  539.     MStripMineButton.setButton("E Radius", Edit, ButtonEditStart, ButtonEditStart + ButtonLength, 5 + 11, (5 + 11) + ButtonHeight, true, "RadiusEdit")
  540.    
  541.     MStripMineButton.setButton("Start", Quarry, ButtonMinStart, ButtonMinStart + ButtonLength, 5 + 15, (5 + 15) + ButtonHeight, true, "Start")
  542.     MStripMineButton.setButton("Reset", Quarry, ButtonPlusStart, ButtonPlusStart + ButtonLength, 5 + 15, (5 + 15) + ButtonHeight, true, "Reset")
  543.    
  544.     -- Move Buttons on monitor
  545.    
  546.     MMoveButton.setButton("H", Do, BeginMonitor, BeginMonitor + 2, BottomMonitor - 5, BottomMonitor - 3, true, "GoHome")
  547.     MMoveButton.setButton("G", Do, BeginMonitor + 6, BeginMonitor + 8, BottomMonitor - 5, BottomMonitor - 3, true, "GoTo")
  548.     MMoveButton.setButton("W", Move, BeginMonitor + 3, BeginMonitor + 5, BottomMonitor - 5, BottomMonitor - 3, true, "forward")
  549.     MMoveButton.setButton("S", Move, BeginMonitor + 3, BeginMonitor + 5, BottomMonitor - 2, BottomMonitor, true, "back")
  550.     MMoveButton.setButton("A", Move, BeginMonitor, BeginMonitor + 2, BottomMonitor - 2, BottomMonitor, true, "left")
  551.     MMoveButton.setButton("D", Move, BeginMonitor + 6, BeginMonitor + 8, BottomMonitor - 2, BottomMonitor, true, "right")
  552.     MMoveButton.setButton("R", Move, BeginMonitor + 10, BeginMonitor + 12, BottomMonitor - 5, BottomMonitor - 3, true, "up")
  553.     MMoveButton.setButton("F", Move, BeginMonitor + 10, BeginMonitor + 12, BottomMonitor - 2, BottomMonitor, true, "down")
  554.     MMoveButton.setButton("-) ^", Dig, BeginMonitor + 14, BeginMonitor + 18, BottomMonitor - 8, BottomMonitor - 6, true, "up")
  555.     MMoveButton.setButton("-)  ", Dig, BeginMonitor + 14, BeginMonitor + 18, BottomMonitor - 5, BottomMonitor - 3, true, "forward")
  556.     MMoveButton.setButton("-) v", Dig, BeginMonitor + 14, BeginMonitor + 18, BottomMonitor - 2, BottomMonitor, true, "down")
  557.     MMoveButton.setButton("P ^", Place, BeginMonitor + 20, BeginMonitor + 23, BottomMonitor - 8, BottomMonitor - 6, true, "up")
  558.     MMoveButton.setButton("P  ", Place, BeginMonitor + 20, BeginMonitor + 23, BottomMonitor - 5, BottomMonitor - 3, true, "forward")
  559.     MMoveButton.setButton("P v", Place, BeginMonitor + 20, BeginMonitor + 23, BottomMonitor - 2, BottomMonitor, true, "down")
  560.     MMoveButton.setButton("S ^", Suck, BeginMonitor + 25, BeginMonitor + 28, BottomMonitor - 8, BottomMonitor - 6, true, "up")
  561.     MMoveButton.setButton("S  ", Suck, BeginMonitor + 25, BeginMonitor + 28, BottomMonitor - 5, BottomMonitor - 3, true, "forward")
  562.     MMoveButton.setButton("S v", Suck, BeginMonitor + 25, BeginMonitor + 28, BottomMonitor - 2, BottomMonitor, true, "down")
  563.     MMoveButton.setButton("D ^", Drop, BeginMonitor + 30, BeginMonitor + 33, BottomMonitor - 8, BottomMonitor - 6, true, "up")
  564.     MMoveButton.setButton("D  ", Drop, BeginMonitor + 30, BeginMonitor + 33, BottomMonitor - 5, BottomMonitor - 3, true, "forward")
  565.     MMoveButton.setButton("D v", Drop, BeginMonitor + 30, BeginMonitor + 33, BottomMonitor - 2, BottomMonitor, true, "down")
  566.    
  567.    
  568. end
  569.  
  570. function Load()
  571.    
  572.     if not(WModem) then
  573.        
  574.         print("No WirelessModem Found !")
  575.         error()
  576.        
  577.     end
  578.    
  579. end
  580.  
  581. function checkForTurtles()
  582.    
  583.     local Event, Side, SId, RId, Message
  584.    
  585.     while Message == nil do
  586.        
  587.         local Data = {What = "Command", Command = "/CH3CK/"}
  588.        
  589.         WModem.Send(Computer.System.Modem.ServerID, Computer.System.Modem.OwnID, Pack(Data))
  590.        
  591.         local timer = System.startTimer(5)
  592.        
  593.         Event, Side, SId, RId, Message = System.pullEvent("modem_message")
  594.        
  595.     end
  596.    
  597.     Turtles = UnPack(Message)
  598.    
  599. end
  600.  
  601.  
  602. function LoadSettings()
  603.    
  604.     local File = fs.exists("/Progs/.Data/.Settings.set")
  605.     local Data
  606.    
  607.     if File then
  608.        
  609.         Data = Functions.LoadFile("/Progs/.Data/.Settings.set")
  610.        
  611.         Computer.System.First = Data.First
  612.         Computer.System.Modem.OwnID = Data.ComputerId
  613.         Computer.System.Modem.ServerID = Data.ServerId
  614.         Computer.System.Nether = Data.Nether
  615.         Computer.System.Modem.SharedID = Data.CharedChannelId
  616.         Computer.System.ComputerName = Data.ComputerName
  617.        
  618.     else
  619.        
  620.         if Computer.System.First == true then
  621.            
  622.             Asking()
  623.            
  624.             Computer.System.First = false
  625.            
  626.         end
  627.        
  628.         SaveSettings()
  629.        
  630.     end
  631.    
  632. end
  633.  
  634. function SaveSettings()
  635.    
  636.     local Data = {First = Computer.System.First, ComputerName = Computer.System.ComputerName, ServerId = Computer.System.Modem.ServerID, ComputerId = Computer.System.Modem.OwnID, CharedChannelId = Computer.System.Modem.SharedID, Nether = Computer.System.Nether}
  637.    
  638.     local Map = fs.exists("/Progs/.Data")
  639.    
  640.     if not(Map) then
  641.        
  642.         fs.makeDir("/Progs/.Data")
  643.        
  644.     end
  645.    
  646.     Functions.SaveFile("/Progs/.Data/.Settings.set", "w", Data)
  647.    
  648. end
  649.  
  650. function Asking()
  651.    
  652.     Monitor[0].clear()
  653.     Monitor[0].setCursorPos(1, 1)
  654.     print("Welcome :-D")
  655.     print(" ")
  656.     write("Computer name: ")
  657.     Computer.System.ComputerName = read()
  658.    
  659.     write("Computer ID: ")
  660.     Computer.System.Modem.OwnID = tonumber(read())
  661.    
  662.     write("Chared Channel Id: ")
  663.     Computer.System.Modem.SharedID = tonumber(read())
  664.    
  665.     write("ServerId: ")
  666.     Computer.System.Modem.ServerID = tonumber(read())
  667.    
  668.     write("Nether Y/N: ")
  669.    
  670.     local Event, Key, IsHeld = System.pullEvent("key")
  671.    
  672.     if Key == keys.y then
  673.        
  674.         Computer.System.Nether = true
  675.        
  676.     else
  677.        
  678.         Computer.System.Nether = false
  679.        
  680.     end
  681.    
  682.     print(tostring(Nether))
  683.    
  684. end
  685.  
  686.  
  687. -- Script Check and Update from the Server
  688.  
  689. function CheckVersion()
  690.    
  691.     Temp.OldVersion = {}
  692.     Temp.OldVersion.A = tonumber(string.sub (Version, 1, 1))
  693.     Temp.OldVersion.B = tonumber(string.sub (Version, 3, 3))
  694.     Temp.OldVersion.C = tonumber(string.sub (Version, 5, 5))
  695.    
  696.     local file = fs.exists("/Progs/.Data/.Version.txt")
  697.    
  698.     if not(file) then
  699.        
  700.         local map = fs.exists("/Progs/.Data/")
  701.        
  702.         if not(map) then
  703.            
  704.             fs.makeDir("/Progs/.Data/")
  705.            
  706.         end
  707.        
  708.         shell.run("pastebin get tRmvEU8B /Progs/.Data/.Version.txt")
  709.        
  710.         local NewComputerVersion
  711.        
  712.         NewComputerVersion = Functions.LoadFile("/Progs/.Data/.Version.txt")
  713.        
  714.         Temp.NewVersion = {}
  715.         Temp.NewVersion.A = tonumber(string.sub(NewComputerVersion, 1, 1))
  716.         Temp.NewVersion.B = tonumber(string.sub(NewComputerVersion, 3, 3))
  717.         Temp.NewVersion.C = tonumber(string.sub(NewComputerVersion, 5, 5))
  718.        
  719.         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
  720.            
  721.             file = fs.exists("/Progs/.RCT.lua")
  722.            
  723.             if file then
  724.                
  725.                 Functions.DelFile("/Progs/.RCT.lua")
  726.                
  727.             end
  728.            
  729.             shell.run("pastebin get FK9CTc1z /Progs/.RCT.lua")
  730.            
  731.             Text = "Rebooting..."
  732.             Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
  733.             Monitor[0].write(Text)
  734.             sleep(3)
  735.            
  736.             System.reboot()
  737.            
  738.         end
  739.        
  740.     elseif file then
  741.        
  742.         local NewComputerVersion
  743.        
  744.         Functions.DelFile("/Progs/.Data/.Version.txt")
  745.         shell.run("pastebin get tRmvEU8B /Progs/.Data/.Version.txt")
  746.        
  747.         NewComputerVersion = Functions.LoadFile("/Progs/.Data/.Version.txt")
  748.        
  749.         Temp.NewVersion = {}
  750.         Temp.NewVersion.A = tonumber(string.sub(NewComputerVersion, 1, 1))
  751.         Temp.NewVersion.B = tonumber(string.sub(NewComputerVersion, 3, 3))
  752.         Temp.NewVersion.C = tonumber(string.sub(NewComputerVersion, 5, 5))
  753.        
  754.         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
  755.            
  756.             file = fs.exists("/Progs/.RCT.lua")
  757.            
  758.             if file then
  759.                
  760.                 Functions.DelFile("/Progs/.RCT.lua")
  761.                
  762.             end
  763.            
  764.             shell.run("pastebin get FK9CTc1z /Progs/.RCT.lua")
  765.            
  766.             Text = "Rebooting..."
  767.             Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
  768.             Monitor[0].write(Text)
  769.             sleep(3)
  770.            
  771.             System.reboot()
  772.            
  773.         end
  774.        
  775.     end
  776.    
  777. end
  778.  
  779. function TestMonitor()
  780.  
  781.     Monitor[1].setTextScale(1)
  782.    
  783.     local mx, my = Monitor[1].getSize()
  784.    
  785.     if mx < 40 or my < 27 then
  786.        
  787.         Monitor[1].setTextScale(0.5)
  788.        
  789.     else
  790.        
  791.         Monitor[1].setTextScale(1)
  792.        
  793.     end
  794.    
  795.     MMoveButton.setMonitor(true)
  796.     MMoveButton.setColors(Color.Red, Color.Black, Color.Lime, Color.Black)
  797.    
  798.     MMenuButton.setMonitor(true)
  799.     MMenuButton.setColors(Color.Blue, Color.Black, Color.White, Color.Black)
  800.    
  801.     MINVButton.setMonitor(true)
  802.     MINVButton.setColors(Color.Yellow, Color.Black, Color.Lime, Color.Black)
  803.    
  804.     MExtraButton.setMonitor(true)
  805.     MExtraButton.setColors(Color.Orange, Color.Black, Color.Red, Color.Black)
  806.    
  807.     MStripMineButton.setMonitor(true)
  808.     MStripMineButton.setColors(Color.Yellow, Color.Black, Color.Lime, Color.Black)
  809.    
  810. end
  811.  
  812. function Startup()
  813.    
  814.     Functions.SetColors(Monitor[0], Color.Black, Color.White)
  815.    
  816.     Monitor[0].clear()
  817.     Monitor[0].setCursorPos(1, 1)
  818.    
  819.     local Text = "Loading..."
  820.    
  821.     Monitor[0].clear()
  822.     Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) - 1)
  823.     print(Text)
  824.    
  825.     System.pullEvent = System.pullEventRaw
  826.    
  827.     Text = "Settings"
  828.     Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
  829.     Monitor[0].clearLine()
  830.     Monitor[0].write(Text)
  831.     sleep(math.random(0.5, 2.0))
  832.    
  833.     LoadSettings()
  834.    
  835.     Monitor[0].clear()
  836.     Monitor[0].setCursorPos(1, 1)
  837.    
  838.     if (WModem) then
  839.        
  840.         Text = "Setting Channel"
  841.         Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
  842.         Monitor[0].clearLine()
  843.        
  844.         Monitor[0].write(Text)
  845.         sleep(math.random(0.5, 2.0))
  846.        
  847.         WModem.closeAll()
  848.         WModem.open(Computer.System.Modem.OwnID)
  849.        
  850.     elseif not(WModem) then
  851.        
  852.         Text = "No Wireless Modem Found !"
  853.         Monitor[0].clear()
  854.         Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
  855.        
  856.         if (Monitor[0].isColor) then
  857.             C1 = Color.Red
  858.             C2 = Color.Black
  859.         end
  860.        
  861.         Functions.SetColors(Monitor[0], C1, C2)
  862.        
  863.         HadError(Text)
  864.        
  865.     end
  866.    
  867.     if (Monitor[1]) then
  868.        
  869.         Text = "Setting Monitor Files"
  870.         Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
  871.         Monitor[0].clearLine()
  872.        
  873.         Monitor[0].write(Text)
  874.         sleep(math.random(0.5, 2.0))
  875.        
  876.         file = fs.exists("/Progs/Api/MMoveButton.lua")
  877.         if not(file) then
  878.             shell.run("pastebin get mKpxpWmZ /Progs/Api/MMoveButton.lua")
  879.         end
  880.        
  881.         file = fs.exists("/Progs/Api/MMenuButton.lua")
  882.         if not(file) then
  883.             shell.run("pastebin get mKpxpWmZ /Progs/Api/MMenuButton.lua")
  884.         end
  885.        
  886.         file = fs.exists("/Progs/Api/MINVButton.lua")
  887.         if not(file) then
  888.             shell.run("pastebin get mKpxpWmZ /Progs/Api/MINVButton.lua")
  889.         end
  890.        
  891.         file = fs.exists("/Progs/Api/MExtraButton.lua")
  892.         if not(file) then
  893.             shell.run("pastebin get mKpxpWmZ /Progs/Api/MExtraButton.lua")
  894.         end
  895.        
  896.         file = fs.exists("/Progs/Api/MStripMineButton.lua")
  897.         if not(file) then
  898.             shell.run("pastebin get mKpxpWmZ /Progs/Api/MStripMineButton.lua")
  899.         end
  900.        
  901.         System.loadAPI("/Progs/Api/MMoveButton.lua")
  902.         System.loadAPI("/Progs/Api/MMenuButton.lua")
  903.         System.loadAPI("/Progs/Api/MINVButton.lua")
  904.         System.loadAPI("/Progs/Api/MExtraButton.lua")
  905.         System.loadAPI("/Progs/Api/MStripMineButton.lua")
  906.        
  907.         TestMonitor()
  908.        
  909.     elseif not(Monitor[1]) then
  910.        
  911.         Text = "No Monitor Found !"
  912.         Monitor[0].clear()
  913.         Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
  914.        
  915.         if (Monitor[0].isColor) then
  916.             C1 = Color.Red
  917.             C2 = Color.Black
  918.         end
  919.        
  920.         Functions.SetColors(Monitor[0], C1, C2)
  921.        
  922.         Monitor[0].write(Text)
  923.         sleep(math.random(0.5, 2.0))
  924.        
  925.         Functions.SetColors(Monitor[0], Color.Black, Color.White)
  926.        
  927.     end
  928.    
  929.     Functions.SetColors(Monitor[0], Color.Black, Color.White)
  930.     Text = "Computer/Turtle Name"
  931.     Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
  932.     Monitor[0].write(Text)
  933.     sleep(math.random(0.5, 2.0))
  934.    
  935.     System.setComputerLabel(Computer.System.ComputerName)
  936.    
  937.     Text = "Updating Version"
  938.     Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
  939.     Monitor[0].clearLine()
  940.     Monitor[0].write(Text)
  941.     sleep(math.random(0.5, 2.0))
  942.    
  943.     CheckVersion()
  944.    
  945.     Text = "Check Turtles"
  946.     Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
  947.     Monitor[0].clearLine()
  948.     Monitor[0].write(Text)
  949.     sleep(math.random(0.5, 2.0))
  950.    
  951. end
  952.  
  953.  
  954. function drawMonitor()
  955.    
  956.     Monitor[1].clear()
  957.     Monitor[1].setCursorPos(1, 1)
  958.    
  959.     local mx, my = Monitor[1].getSize()
  960.     local BottomMonitor = my - 1
  961.     local TopMonitor = 1 + 1
  962.     local EndMonitor = mx + 1
  963.     local BeginMonitor = 1 + 1
  964.    
  965.     if (Computer.Connection.Connected) then
  966.        
  967.         if nMonitorOption == 1 then
  968.            
  969.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 2)
  970.             Monitor[1].write("Conneted ID: "..tostring(Computer.Connection.ConnectedTurtle.Id))
  971.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 3)
  972.             Monitor[1].write("Conneted Name: "..Computer.Connection.ConnectedTurtle.Name)
  973.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 4)
  974.             Monitor[1].write("Doing: "..Computer.Connection.ConnectedTurtle.Doing)
  975.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 5)
  976.             Monitor[1].write("Fuel Level: "..Computer.Connection.ConnectedTurtle.FuelLevel)
  977.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 6)
  978.             Monitor[1].write("Cor: X: "..tostring(Computer.Connection.ConnectedTurtle.Cor.X).." Y: "..tostring(Computer.Connection.ConnectedTurtle.Cor.Y).." Z: "..tostring(Computer.Connection.ConnectedTurtle.Cor.Z))
  979.             local R = GetOrientNames(Computer.Connection.ConnectedTurtle.Cor.R)
  980.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 7)
  981.             Monitor[1].write("Orientation: "..R)
  982.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 8)
  983.             Monitor[1].write("Up: "..Computer.Connection.ConnectedTurtle.Inspect.Up.name)
  984.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 9)
  985.             Monitor[1].write("Forward: "..Computer.Connection.ConnectedTurtle.Inspect.Forward.name)
  986.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 10)
  987.             Monitor[1].write("Down: "..Computer.Connection.ConnectedTurtle.Inspect.Down.name)
  988.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 11)
  989.             Monitor[1].write("Compare: "..Computer.Connection.ConnectedTurtle.Compare)
  990.             Monitor[1].setCursorPos(BeginMonitor, TopMonitor + 12)
  991.             Monitor[1].write("Detect: "..Computer.Connection.ConnectedTurtle.Detect)
  992.            
  993.         elseif nMonitorOption == 2 then
  994.            
  995.             MINVButton.onScreen()
  996.            
  997.             if nMonitorTurtleInventoryOption >= 1 and nMonitorTurtleInventoryOption <= 16 then
  998.                
  999.                 if Computer.Connection.ConnectedTurtle.Slot[nMonitorTurtleInventoryOption] == nil then
  1000.                    
  1001.                     Computer.Connection.ConnectedTurtle.Slot[nMonitorTurtleInventoryOption] = { Count = 0, Data = { name = ":Nothing" }}
  1002.                    
  1003.                 else
  1004.                    
  1005.                     if Computer.Connection.ConnectedTurtle.Slot[nMonitorTurtleInventoryOption].Count == nil then
  1006.                        
  1007.                         Computer.Connection.ConnectedTurtle.Slot[nMonitorTurtleInventoryOption].Count = 0
  1008.                        
  1009.                     end
  1010.                    
  1011.                     if Computer.Connection.ConnectedTurtle.Slot[nMonitorTurtleInventoryOption].Data == nil then
  1012.                        
  1013.                         Computer.Connection.ConnectedTurtle.Slot[nMonitorTurtleInventoryOption].Data = { name = ":Nothing" }
  1014.                        
  1015.                     end
  1016.                    
  1017.                 end
  1018.                
  1019.                 MINVButton.setLabel(BeginMonitor, TopMonitor + 19, "Name: "..string.sub(Computer.Connection.ConnectedTurtle.Slot[nMonitorTurtleInventoryOption].Data.name, string.find(Computer.Connection.ConnectedTurtle.Slot[nMonitorTurtleInventoryOption].Data.name, ":")+1))
  1020.                 MINVButton.setLabel(BeginMonitor, TopMonitor + 20, "Count: "..tostring(Computer.Connection.ConnectedTurtle.Slot[nMonitorTurtleInventoryOption].Count))
  1021.                
  1022.             end
  1023.            
  1024.         elseif nMonitorOption == 3 then
  1025.            
  1026.             if Computer.Connection.ConnectedTurtle.Status then
  1027.                
  1028.                 MStripMineButton.onScreen()
  1029.                
  1030.                 MStripMineButton.setLabel(BeginMonitor, TopMonitor + 5, "Cor:")
  1031.                
  1032.                 MStripMineButton.setLabel(BeginMonitor + 5, TopMonitor + 4, "X:")
  1033.                
  1034.                 MStripMineButton.setLabel(BeginMonitor + 26, TopMonitor + 4, tostring(GoToX))
  1035.                
  1036.                 MStripMineButton.setLabel(BeginMonitor + 5, TopMonitor + 7, "Z:")
  1037.                
  1038.                 MStripMineButton.setLabel(BeginMonitor + 26, TopMonitor + 7, tostring(GoToZ))
  1039.                
  1040.                 MStripMineButton.setLabel(BeginMonitor + 5, TopMonitor + 11, "Layer: ")
  1041.                
  1042.                 MStripMineButton.setLabel(BeginMonitor + 26, TopMonitor + 11, tostring(Layer))
  1043.                
  1044.                 MStripMineButton.setLabel(BeginMonitor + 5, TopMonitor + 15, "Radius: ")
  1045.                
  1046.                 MStripMineButton.setLabel(BeginMonitor + 26, TopMonitor + 15, tostring(Radius))
  1047.                
  1048.             end
  1049.            
  1050.         end
  1051.        
  1052.         MMenuButton.onScreen()
  1053.        
  1054.         if MButtonn and Computer.Connection.ConnectedTurtle.Status then
  1055.            
  1056.             MMoveButton.onScreen()
  1057.            
  1058.         end
  1059.        
  1060.     end
  1061.    
  1062. end
  1063.  
  1064.  
  1065. function drawMenu()
  1066.    
  1067.     Monitor[0].clear()
  1068.    
  1069.     Logo.drawLogo(Monitor[0], "Sub", 1, 1)
  1070.    
  1071.     Monitor[0].setCursorPos(w-(NameLen+3), 2)
  1072.    
  1073.     if (Computer.Connection.Connected) then
  1074.        
  1075.         if nOption == 1 then
  1076.            
  1077.             Monitor[0].write("System")
  1078.            
  1079.         elseif nOption == 2 then
  1080.        
  1081.             Monitor[0].write("Info Turtle")
  1082.            
  1083.         elseif nOption == 3 then
  1084.            
  1085.             Monitor[0].write("Turtle System")
  1086.            
  1087.         elseif nOption == 4 then
  1088.            
  1089.             Monitor[0].write("Turtle Movements")
  1090.            
  1091.         elseif nOption == 5 then
  1092.            
  1093.             Monitor[0].write("Turtle Program's")
  1094.            
  1095.         else
  1096.            
  1097.         end
  1098.        
  1099.     else
  1100.        
  1101.         if nOption == 1 then
  1102.            
  1103.             Monitor[0].write("System")
  1104.            
  1105.         else
  1106.            
  1107.         end
  1108.        
  1109.     end
  1110.    
  1111.     Functions.SetColors(Monitor[0], Color.White, Color.Black)
  1112.    
  1113.     Monitor[0].setCursorPos(1, h)
  1114.     Monitor[0].write("Press 'Q' to quit.")
  1115.    
  1116.     Functions.SetColors(Monitor[0], Color.Black, Color.White)
  1117.    
  1118. end
  1119.  
  1120. function drawFrontend()
  1121.    
  1122.     Functions.printCentered(Monitor[0], math.floor(h/2) -3, Functions.PadString("  Head Menu",NameLen))
  1123.    
  1124.     if (Computer.Connection.Connected) then
  1125.        
  1126.         Functions.printCentered(Monitor[0], math.floor(h/2) -1, ((nOption == 1) and string.format("%s%s",Functions.PadString("[ System",NameLen-1),"]") or Functions.PadString("  System",NameLen)))
  1127.         Functions.printCentered(Monitor[0], math.floor(h/2) +0, ((nOption == 2) and string.format("%s%s",Functions.PadString("[ T Info",NameLen-1),"]") or Functions.PadString("  T Info",NameLen)))
  1128.         Functions.printCentered(Monitor[0], math.floor(h/2) +1, ((nOption == 3) and string.format("%s%s",Functions.PadString("[ T System",NameLen-1),"]") or Functions.PadString("  T System",NameLen)))
  1129.         Functions.printCentered(Monitor[0], math.floor(h/2) +2, ((nOption == 4) and string.format("%s%s",Functions.PadString("[ T Movements",NameLen-1),"]") or Functions.PadString("  T Movements",NameLen)))
  1130.         Functions.printCentered(Monitor[0], math.floor(h/2) +3, ((nOption == 5) and string.format("%s%s",Functions.PadString("[ T Program's",NameLen-1),"]") or Functions.PadString("  T Program's",NameLen)))
  1131.        
  1132.     else
  1133.        
  1134.         Functions.printCentered(Monitor[0], math.floor(h/2) -1, ((nOption == 1) and string.format("%s%s",Functions.PadString("[ System",NameLen-1),"]") or Functions.PadString("  System",NameLen)))
  1135.        
  1136.     end
  1137.    
  1138. end
  1139.  
  1140.  
  1141. function drawSystemMenu()
  1142.    
  1143.     Monitor[0].clear()
  1144.     Monitor[0].setCursorPos(1, 1)
  1145.     Monitor[0].write("Name: "..Computer.System.ComputerName)
  1146.    
  1147.     Monitor[0].setCursorPos(w-(NameLen+3), 2)
  1148.    
  1149.     if (Computer.Connection.Connected) then
  1150.        
  1151.         if nSystemOption == 1 then
  1152.            
  1153.             Monitor[0].write("Disconnect")
  1154.            
  1155.         elseif nSystemOption == 2 then
  1156.        
  1157.             Monitor[0].write("Reboot")
  1158.            
  1159.         elseif nSystemOption == 3 then
  1160.            
  1161.             Monitor[0].write("Reset")
  1162.            
  1163.         elseif nSystemOption == 4 then
  1164.            
  1165.             Monitor[0].write("Uninstall")
  1166.            
  1167.         else
  1168.            
  1169.         end
  1170.        
  1171.     else
  1172.        
  1173.         if nSystemOption == 1 then
  1174.            
  1175.             Monitor[0].write("Connect")
  1176.            
  1177.         elseif nSystemOption == 2 then
  1178.        
  1179.             Monitor[0].write("Reboot")
  1180.            
  1181.         elseif nSystemOption == 3 then
  1182.            
  1183.             Monitor[0].write("Reset")
  1184.            
  1185.         else
  1186.            
  1187.         end
  1188.        
  1189.     end
  1190.    
  1191.     Functions.SetColors(Monitor[0], Color.White, Color.Black)
  1192.    
  1193.     Monitor[0].setCursorPos(1, h)
  1194.     Monitor[0].write("Press 'B' to go back.")
  1195.    
  1196.     Functions.SetColors(Monitor[0], Color.Black, Color.White)
  1197.    
  1198. end
  1199.  
  1200. function drawSystemFrontend()
  1201.    
  1202.     Functions.printCentered(Monitor[0], math.floor(h/2) -3, Functions.PadString("  System Menu",NameLen))
  1203.    
  1204.     if (Computer.Connection.Connected) then
  1205.        
  1206.         Functions.printCentered(Monitor[0], math.floor(h/2) -1, ((nSystemOption == 1) and string.format("%s%s",Functions.PadString("[ Disconnect",NameLen-1),"]") or Functions.PadString("  Disconnect",NameLen)))
  1207.         Functions.printCentered(Monitor[0], math.floor(h/2) +0, ((nSystemOption == 2) and string.format("%s%s",Functions.PadString("[ Reboot",NameLen-1),"]") or Functions.PadString("  Reboot",NameLen)))
  1208.         Functions.printCentered(Monitor[0], math.floor(h/2) +1, ((nSystemOption == 3) and string.format("%s%s",Functions.PadString("[ Reset",NameLen-1),"]") or Functions.PadString("  Reset",NameLen)))
  1209.         Functions.printCentered(Monitor[0], math.floor(h/2) +2, ((nSystemOption == 4) and string.format("%s%s",Functions.PadString("[ Uninstall",NameLen-1),"]") or Functions.PadString("  Uninstall",NameLen)))
  1210.        
  1211.     else
  1212.        
  1213.         Functions.printCentered(Monitor[0], math.floor(h/2) -1, ((nSystemOption == 1) and string.format("%s%s",Functions.PadString("[ Connect",NameLen-1),"]") or Functions.PadString("  Connect",NameLen)))
  1214.         Functions.printCentered(Monitor[0], math.floor(h/2) +0, ((nSystemOption == 2) and string.format("%s%s",Functions.PadString("[ Reboot",NameLen-1),"]") or Functions.PadString("  Reboot",NameLen)))
  1215.         Functions.printCentered(Monitor[0], math.floor(h/2) +1, ((nSystemOption == 3) and string.format("%s%s",Functions.PadString("[ Reset",NameLen-1),"]") or Functions.PadString("  Reset",NameLen)))
  1216.         Functions.printCentered(Monitor[0], math.floor(h/2) +2, ((nSystemOption == 4) and string.format("%s%s",Functions.PadString("[ Uninstall",NameLen-1),"]") or Functions.PadString("  Uninstall",NameLen)))
  1217.        
  1218.     end
  1219.    
  1220. end
  1221.  
  1222.  
  1223. function drawTurtlesFrontend()
  1224.    
  1225.     checkForTurtles()
  1226.    
  1227.     Functions.printCentered(Monitor[0], 1, "Turtles ID's: ")
  1228.    
  1229.     for i = 1, #Turtles do
  1230.        
  1231.         Functions.printCentered(Monitor[0], i+2, ((nTurtlesOption == i) and string.format("%s%s",Functions.PadString("[ "..tostring(Turtles[i].Id),NameLen-1),"]") or Functions.PadString("  "..tostring(Turtles[i].Id),NameLen)))
  1232.        
  1233.     end
  1234.    
  1235. end
  1236.  
  1237.  
  1238. function drawTurtleInfo()
  1239.    
  1240.     checkForTurtles()
  1241.    
  1242.     for i = 1, #Turtles do
  1243.        
  1244.         if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  1245.            
  1246.             Computer.Connection.ConnectedTurtle = Turtles[i]
  1247.            
  1248.         end
  1249.        
  1250.     end
  1251.    
  1252.     Monitor[0].clear()
  1253.    
  1254.     if nTurtleInfoOption == 1 then
  1255.        
  1256.         local a = 1
  1257.        
  1258.         Functions.printCentered(Monitor[0], a, "Turtle Info page "..tostring(nTurtleInfoOption))
  1259.        
  1260.         a = a + 2
  1261.        
  1262.         Functions.printCentered(Monitor[0], a, "Conneted ID: "..tostring(Computer.Connection.ConnectedTurtle.Id))
  1263.         a = a + 1
  1264.         Functions.printCentered(Monitor[0], a, "Conneted Name: "..Computer.Connection.ConnectedTurtle.Name)
  1265.         a = a + 1
  1266.         Functions.printCentered(Monitor[0], a, "Groupstate: "..tostring(Computer.Connection.ConnectedTurtle.GroupState))
  1267.         a = a + 1
  1268.         Functions.printCentered(Monitor[0], a, "Doing: "..Computer.Connection.ConnectedTurtle.Doing)
  1269.         a = a + 1
  1270.         Functions.printCentered(Monitor[0], a, "Fuel Level: "..Computer.Connection.ConnectedTurtle.FuelLevel)
  1271.         a = a + 1
  1272.         Functions.printCentered(Monitor[0], a, "Cor: X: "..tostring(Computer.Connection.ConnectedTurtle.Cor.X).." Y: "..tostring(Computer.Connection.ConnectedTurtle.Cor.Y).." Z: "..tostring(Computer.Connection.ConnectedTurtle.Cor.Z))
  1273.         local R = GetOrientNames(Computer.Connection.ConnectedTurtle.Cor.R)
  1274.         a = a + 1
  1275.         Functions.printCentered(Monitor[0], a, "Orientation: "..R)
  1276.         a = a + 1
  1277.         Functions.printCentered(Monitor[0], a, "Up: "..Computer.Connection.ConnectedTurtle.Inspect.Up.name)
  1278.         a = a + 1
  1279.         Functions.printCentered(Monitor[0], a, "Forward: "..Computer.Connection.ConnectedTurtle.Inspect.Forward.name)
  1280.         a = a + 1
  1281.         Functions.printCentered(Monitor[0], a, "Down: "..Computer.Connection.ConnectedTurtle.Inspect.Down.name)
  1282.         a = a + 1
  1283.         Functions.printCentered(Monitor[0], a, "Compare: "..Computer.Connection.ConnectedTurtle.Compare)
  1284.         a = a + 1
  1285.         Functions.printCentered(Monitor[0], a, "Detect: "..Computer.Connection.ConnectedTurtle.Detect)
  1286.         a = a + 1
  1287.         Functions.printCentered(Monitor[0], a, "")
  1288.         a = a + 1
  1289.         Functions.printCentered(Monitor[0], a, "")
  1290.         a = a + 1
  1291.         Functions.printCentered(Monitor[0], a, "")
  1292.         a = a + 1
  1293.         Functions.printCentered(Monitor[0], a, "")
  1294.        
  1295.     elseif nTurtleInfoOption == 2 then
  1296.        
  1297.         local a = 1
  1298.        
  1299.         Functions.printCentered(Monitor[0], a, "Turtle Info page "..tostring(nTurtleInfoOption))
  1300.        
  1301.         a = a + 2
  1302.        
  1303.         Functions.printCentered(Monitor[0], a, "Test")
  1304.         a = a + 1
  1305.         Functions.printCentered(Monitor[0], a, "")
  1306.         a = a + 1
  1307.         Functions.printCentered(Monitor[0], a, "")
  1308.         a = a + 1
  1309.         Functions.printCentered(Monitor[0], a, "")
  1310.         a = a + 1
  1311.         Functions.printCentered(Monitor[0], a, "")
  1312.         a = a + 1
  1313.         Functions.printCentered(Monitor[0], a, "")
  1314.         a = a + 1
  1315.         Functions.printCentered(Monitor[0], a, "")
  1316.         a = a + 1
  1317.         Functions.printCentered(Monitor[0], a, "")
  1318.         a = a + 1
  1319.         Functions.printCentered(Monitor[0], a, "")
  1320.         a = a + 1
  1321.         Functions.printCentered(Monitor[0], a, "")
  1322.         a = a + 1
  1323.         Functions.printCentered(Monitor[0], a, "")
  1324.         a = a + 1
  1325.         Functions.printCentered(Monitor[0], a, "")
  1326.         a = a + 1
  1327.         Functions.printCentered(Monitor[0], a, "")
  1328.         a = a + 1
  1329.         Functions.printCentered(Monitor[0], a, "")
  1330.         a = a + 1
  1331.         Functions.printCentered(Monitor[0], a, "")
  1332.         a = a + 1
  1333.         Functions.printCentered(Monitor[0], a, "")
  1334.        
  1335.     end
  1336.    
  1337.     Functions.SetColors(Monitor[0], Color.White, Color.Black)
  1338.    
  1339.     Monitor[0].setCursorPos(1, h)
  1340.     Monitor[0].write("Press 'B' to go back.")
  1341.    
  1342.     Functions.SetColors(Monitor[0], Color.Black, Color.White)
  1343.    
  1344.    
  1345. end
  1346.  
  1347.  
  1348. function drawTurtleSystemMenu()
  1349.    
  1350.     checkForTurtles()
  1351.    
  1352.     for i = 1, #Turtles do
  1353.        
  1354.         if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  1355.            
  1356.             Computer.Connection.ConnectedTurtle = Turtles[i]
  1357.            
  1358.         end
  1359.        
  1360.     end
  1361.    
  1362.     Monitor[0].clear()
  1363.     Monitor[0].setCursorPos(1, 1)
  1364.     Monitor[0].write("Name: "..Computer.System.ComputerName)
  1365.    
  1366.     Monitor[0].setCursorPos(1, 3)
  1367.     Monitor[0].write("Compare: "..Computer.Connection.ConnectedTurtle.Compare)
  1368.     Monitor[0].setCursorPos(1, 4)
  1369.     Monitor[0].write("Detect: "..Computer.Connection.ConnectedTurtle.Detect)
  1370.    
  1371.     Monitor[0].setCursorPos(w-NameLen, 2)
  1372.    
  1373.     if nTurtleSystemOption == 1 then
  1374.        
  1375.         Monitor[0].write("GroupState")
  1376.        
  1377.     elseif nTurtleSystemOption == 2 then
  1378.    
  1379.         Monitor[0].write("Refuel")
  1380.        
  1381.     elseif nTurtleSystemOption == 3 then
  1382.        
  1383.         Monitor[0].write("Select Slot")
  1384.        
  1385.     elseif nTurtleSystemOption == 4 then
  1386.        
  1387.         Monitor[0].write("Equip")
  1388.        
  1389.     elseif nTurtleSystemOption == 5 then
  1390.    
  1391.         Monitor[0].write("Transfer To")
  1392.        
  1393.     elseif nTurtleSystemOption == 6 then
  1394.        
  1395.         Monitor[0].write("Craft")
  1396.        
  1397.     elseif nTurtleSystemOption == 7 then
  1398.        
  1399.         Monitor[0].write("Detect")
  1400.        
  1401.     elseif nTurtleSystemOption == 8 then
  1402.        
  1403.         Monitor[0].write("Inspect")
  1404.        
  1405.     elseif nTurtleSystemOption == 9 then
  1406.        
  1407.         Monitor[0].write("Compare")
  1408.        
  1409.     elseif nTurtleSystemOption == 10 then
  1410.    
  1411.         Monitor[0].write("Print Log")
  1412.        
  1413.     elseif nTurtleSystemOption == 11 then
  1414.        
  1415.         Monitor[0].write("Reboot")
  1416.        
  1417.     elseif nTurtleSystemOption == 12 then
  1418.        
  1419.         Monitor[0].write("Shutdown")
  1420.        
  1421.     elseif nTurtleSystemOption == 13 then
  1422.    
  1423.         Monitor[0].write("Reset Turtle")
  1424.        
  1425.     elseif nTurtleSystemOption == 14 then
  1426.        
  1427.         Monitor[0].write("")
  1428.        
  1429.     elseif nTurtleSystemOption == 15 then
  1430.        
  1431.         Monitor[0].write("")
  1432.        
  1433.     elseif nTurtleSystemOption == 16 then
  1434.        
  1435.         Monitor[0].write("")
  1436.        
  1437.     else
  1438.        
  1439.     end
  1440.    
  1441.     Functions.SetColors(Monitor[0], Color.White, Color.Black)
  1442.    
  1443.     Monitor[0].setCursorPos(1, h)
  1444.     Monitor[0].write("Press 'B' to go back.")
  1445.    
  1446.     Functions.SetColors(Monitor[0], Color.Black, Color.White)
  1447.    
  1448. end
  1449.  
  1450. function drawTurtleSystemFrontend()
  1451.    
  1452.     Functions.printCentered(Monitor[0], math.floor(h/2) -3, Functions.PadString("  System Menu",NameLen))
  1453.     Functions.printQuart(Monitor[0], math.floor(h/2) -1, ((nTurtleSystemOption == 1) and string.format("%s%s",Functions.PadString("[ GroupState",NameLen-1),"]") or Functions.PadString("  GroupState",NameLen)))
  1454.     Functions.printQuart(Monitor[0], math.floor(h/2) +0, ((nTurtleSystemOption == 2) and string.format("%s%s",Functions.PadString("[ Refuel",NameLen-1),"]") or Functions.PadString("  Refuel",NameLen)))
  1455.     Functions.printQuart(Monitor[0], math.floor(h/2) +1, ((nTurtleSystemOption == 3) and string.format("%s%s",Functions.PadString("[ Select Slot",NameLen-1),"]") or Functions.PadString("  Select Slot",NameLen)))
  1456.     Functions.printQuart(Monitor[0], math.floor(h/2) +2, ((nTurtleSystemOption == 4) and string.format("%s%s",Functions.PadString("[ Equip",NameLen-1),"]") or Functions.PadString("  Equip",NameLen)))
  1457.     Functions.printQuart(Monitor[0], math.floor(h/2) +3, ((nTurtleSystemOption == 5) and string.format("%s%s",Functions.PadString("[ Transfer To",NameLen-1),"]") or Functions.PadString("  Transfer To",NameLen)))
  1458.     Functions.printQuart(Monitor[0], math.floor(h/2) +4, ((nTurtleSystemOption == 6) and string.format("%s%s",Functions.PadString("[ Craft",NameLen-1),"]") or Functions.PadString("  Craft",NameLen)))
  1459.     Functions.printQuart(Monitor[0], math.floor(h/2) +5, ((nTurtleSystemOption == 7) and string.format("%s%s",Functions.PadString("[ Detect",NameLen-1),"]") or Functions.PadString("  Detect",NameLen)))
  1460.     Functions.printQuart(Monitor[0], math.floor(h/2) +6, ((nTurtleSystemOption == 8) and string.format("%s%s",Functions.PadString("[ Inspect",NameLen-1),"]") or Functions.PadString("  Inspect",NameLen)))
  1461.     Functions.printQuart(Monitor[0], math.floor(h/2) +7, ((nTurtleSystemOption == 9) and string.format("%s%s",Functions.PadString("[ Compare",NameLen-1),"]") or Functions.PadString("  Compare",NameLen)))
  1462.     Functions.printQuart(Monitor[0], math.floor(h/2) +8, ((nTurtleSystemOption == 10) and string.format("%s%s",Functions.PadString("[ Print Log",NameLen-1),"]") or Functions.PadString("  Print Log",NameLen)))
  1463.     Functions.printThreeQuartNC(Monitor[0], math.floor(h/2) -1, ((nTurtleSystemOption == 11) and string.format("%s%s",Functions.PadString("[ Reboot",NameLen-1),"]") or Functions.PadString("  Reboot",NameLen)))
  1464.     Functions.printThreeQuartNC(Monitor[0], math.floor(h/2) +0, ((nTurtleSystemOption == 12) and string.format("%s%s",Functions.PadString("[ Shutdown",NameLen-1),"]") or Functions.PadString("  Shutdown",NameLen)))
  1465.     Functions.printThreeQuartNC(Monitor[0], math.floor(h/2) +1, ((nTurtleSystemOption == 13) and string.format("%s%s",Functions.PadString("[ Reset Turtle",NameLen-1),"]") or Functions.PadString("  Reset Turtle",NameLen)))
  1466.     Functions.printThreeQuartNC(Monitor[0], math.floor(h/2) +2, ((nTurtleSystemOption == 14) and string.format("%s%s",Functions.PadString("[ ",NameLen-1),"]") or Functions.PadString("  ",NameLen)))
  1467.     Functions.printThreeQuartNC(Monitor[0], math.floor(h/2) +3, ((nTurtleSystemOption == 15) and string.format("%s%s",Functions.PadString("[ ",NameLen-1),"]") or Functions.PadString("  ",NameLen)))
  1468.     Functions.printThreeQuartNC(Monitor[0], math.floor(h/2) +4, ((nTurtleSystemOption == 16) and string.format("%s%s",Functions.PadString("[ ",NameLen-1),"]") or Functions.PadString("  ",NameLen)))
  1469.    
  1470. end
  1471.  
  1472.  
  1473. function drawTurtleEquipFrontend()
  1474.    
  1475.    
  1476.     Functions.printQuart(Monitor[0], math.floor(h/2) +1, Functions.PadString("  ",NameLen))
  1477.     Functions.printQuart(Monitor[0], math.floor(h/2) +2, ((nTurtleEquipOption == 1) and string.format("%s%s",Functions.PadString("[ Left",NameLen-1),"]") or Functions.PadString("  Left",NameLen)))
  1478.     Functions.printQuart(Monitor[0], math.floor(h/2) +3, ((nTurtleEquipOption == 2) and string.format("%s%s",Functions.PadString("[ Right",NameLen-1),"]") or Functions.PadString("  Right",NameLen)))
  1479.     Functions.printQuart(Monitor[0], math.floor(h/2) +4, Functions.PadString("  ",NameLen))
  1480.    
  1481.    
  1482. end
  1483.  
  1484.  
  1485. function drawTurtleDetectFrontend()
  1486.    
  1487.     Functions.printQuart(Monitor[0], math.floor(h/2) +3, Functions.PadString("  ",NameLen))
  1488.     Functions.printQuart(Monitor[0], math.floor(h/2) +4, ((nTurtleDetectOption == 1) and string.format("%s%s",Functions.PadString("[ Forward",NameLen-1),"]") or Functions.PadString("  Forward",NameLen)))
  1489.     Functions.printQuart(Monitor[0], math.floor(h/2) +5, ((nTurtleDetectOption == 2) and string.format("%s%s",Functions.PadString("[ Up",NameLen-1),"]") or Functions.PadString("  Up",NameLen)))
  1490.     Functions.printQuart(Monitor[0], math.floor(h/2) +6, ((nTurtleDetectOption == 3) and string.format("%s%s",Functions.PadString("[ Down",NameLen-1),"]") or Functions.PadString("  Down",NameLen)))
  1491.     Functions.printQuart(Monitor[0], math.floor(h/2) +7, Functions.PadString("  ",NameLen))
  1492.    
  1493. end
  1494.  
  1495. function drawTurtleInspectFrontend()
  1496.    
  1497.     Functions.printQuart(Monitor[0], math.floor(h/2) +4, Functions.PadString("  ",NameLen))
  1498.     Functions.printQuart(Monitor[0], math.floor(h/2) +5, ((nTurtleInspectOption == 1) and string.format("%s%s",Functions.PadString("[ Forward",NameLen-1),"]") or Functions.PadString("  Forward",NameLen)))
  1499.     Functions.printQuart(Monitor[0], math.floor(h/2) +6, ((nTurtleInspectOption == 2) and string.format("%s%s",Functions.PadString("[ Up",NameLen-1),"]") or Functions.PadString("  Up",NameLen)))
  1500.     Functions.printQuart(Monitor[0], math.floor(h/2) +7, ((nTurtleInspectOption == 3) and string.format("%s%s",Functions.PadString("[ Down",NameLen-1),"]") or Functions.PadString("  Down",NameLen)))
  1501.     Functions.printQuart(Monitor[0], math.floor(h/2) +8, Functions.PadString("  ",NameLen))
  1502.    
  1503. end
  1504.  
  1505. function drawTurtleCompareFrontend()
  1506.    
  1507.     Functions.printQuart(Monitor[0], math.floor(h/2) +4, Functions.PadString("  ",NameLen))
  1508.     Functions.printQuart(Monitor[0], math.floor(h/2) +5, ((nTurtleCompareOption == 1) and string.format("%s%s",Functions.PadString("[ Forward",NameLen-1),"]") or Functions.PadString("  Forward",NameLen)))
  1509.     Functions.printQuart(Monitor[0], math.floor(h/2) +6, ((nTurtleCompareOption == 2) and string.format("%s%s",Functions.PadString("[ Up",NameLen-1),"]") or Functions.PadString("  Up",NameLen)))
  1510.     Functions.printQuart(Monitor[0], math.floor(h/2) +7, ((nTurtleCompareOption == 3) and string.format("%s%s",Functions.PadString("[ Down",NameLen-1),"]") or Functions.PadString("  Down",NameLen)))
  1511.     Functions.printQuart(Monitor[0], math.floor(h/2) +8,Functions. PadString("  ",NameLen))
  1512.    
  1513. end
  1514.  
  1515. function drawTurtleInspectInfoFrontend(Table)
  1516.    
  1517.     Monitor[0].clear()
  1518.    
  1519.     local a = 1
  1520.     local HeightA = 19
  1521.    
  1522.     Functions.printCentered(Monitor[0], a, "Inspect")
  1523.    
  1524.     a = a + 2
  1525.    
  1526.     for Mame, Deta in pairs(Table) do
  1527.        
  1528.         if a == HeightA then break end
  1529.        
  1530.         if type(Deta) == "table" then
  1531.            
  1532.             Functions.printCentered(Monitor[0], a, Functions.PadString(Mame.."| ", w-4))
  1533.            
  1534.             a = a + 1
  1535.             if a == HeightA then break end
  1536.            
  1537.             for MName, DEata in pairs(Deta) do
  1538.                
  1539.                 if a == HeightA then break end
  1540.                
  1541.                 if type(DEata) == "table" then
  1542.                    
  1543.                     Functions.printCentered(Monitor[0], a, Functions.PadString(MName.."| ", w-4))
  1544.            
  1545.                     a = a + 1
  1546.                     if a == HeightA then break end
  1547.                    
  1548.                     for MMname, DeAta in pairs(DEata) do
  1549.                        
  1550.                         if a == HeightA then break end
  1551.                        
  1552.                         if type(DeAta) == "table" then
  1553.                            
  1554.                             Functions.printCentered(Monitor[0], a, Functions.PadString(MMname.."| ", w-4))
  1555.            
  1556.                             a = a + 1
  1557.                             if a == HeightA then break end
  1558.                            
  1559.                             for MMnameA, DeAtaA in pairs(DeAta) do
  1560.                                
  1561.                                 if a == HeightA then break end
  1562.                                
  1563.                                 if type(DeAtaA) == "table" then
  1564.                                    
  1565.                                     Functions.printCentered(Monitor[0], a, Functions.PadString(MMnameA.."| ", w-4))
  1566.            
  1567.                                     a = a + 1
  1568.                                     if a == HeightA then break end
  1569.                                    
  1570.                                     for MMnameB, DeAtaB in pairs(DeAtaA) do
  1571.                                        
  1572.                                         if a == HeightA then break end
  1573.                                        
  1574.                                         if type(DeAtaB) == "table" then
  1575.                                            
  1576.                                             Functions.printCentered(Monitor[0], a, Functions.PadString(MMnameB.."| ", w-4))
  1577.            
  1578.                                             a = a + 1
  1579.                                             if a == HeightA then break end
  1580.                                            
  1581.                                             for MMnameC, DeAtaC in pairs(DeAtaB) do
  1582.                                                
  1583.                                                 if a == HeightA then break end
  1584.                                                
  1585.                                                 if type(DeAtaC) ~= "table" then
  1586.                                                    
  1587.                                                     Functions.printCentered(Monitor[0], a, Functions.PadString(MMnameC.."| ", w-4))
  1588.            
  1589.                                                     a = a + 1
  1590.                                                     if a == HeightA then break end
  1591.                                                    
  1592.                                                     if MMnameC ~= nil and DeAtaC ~= nil then
  1593.                                                        
  1594.                                                         Functions.printCentered(Monitor[0], a, Functions.PadString(tostring(DeAtaC), w-4))
  1595.                                                        
  1596.                                                         a = a + 1
  1597.                                                        
  1598.                                                         if a == HeightA then break end
  1599.                                                        
  1600.                                                     end
  1601.                                                    
  1602.                                                 else
  1603.                                                    
  1604.                                                     if a == HeightA then break end
  1605.                                                    
  1606.                                                     Functions.printCentered(Monitor[0], a, Functions.PadString(MMnameC.."| Table Cant Read", w-4))
  1607.                                                    
  1608.                                                     a = a + 1
  1609.                                                    
  1610.                                                     if a == HeightA then break end
  1611.                                                    
  1612.                                                 end
  1613.                                                
  1614.                                             end
  1615.                                            
  1616.                                         else
  1617.                                            
  1618.                                             if a == HeightA then break end
  1619.                                            
  1620.                                             if MMnameB ~= nil and DeAtaB ~= nil then
  1621.                                                
  1622.                                                 Functions.printCentered(Monitor[0], a, Functions.PadString(MMnameB.."| "..tostring(DeAtaB), w-4))
  1623.                                                
  1624.                                                 a = a + 1
  1625.                                                
  1626.                                                 if a == HeightA then break end
  1627.                                                
  1628.                                             end
  1629.                                            
  1630.                                         end
  1631.                                        
  1632.                                     end
  1633.                                    
  1634.                                 else
  1635.                                    
  1636.                                     if a == HeightA then break end
  1637.                                    
  1638.                                     if MMnameA ~= nil and DeAtaA ~= nil then
  1639.                                        
  1640.                                         Functions.printCentered(Monitor[0], a, Functions.PadString(MMnameA.."| "..tostring(DeAtaA), w-4))
  1641.                                        
  1642.                                         a = a + 1
  1643.                                        
  1644.                                         if a == HeightA then break end
  1645.                                        
  1646.                                     end
  1647.                                    
  1648.                                 end
  1649.                                
  1650.                             end
  1651.                            
  1652.                         else
  1653.                            
  1654.                             if a == HeightA then break end
  1655.                            
  1656.                             if MMname ~= nil and DeAta ~= nil then
  1657.                                
  1658.                                 Functions.printCentered(Monitor[0], a, Functions.PadString(MMname.."| "..tostring(DeAta), w-4))
  1659.                                
  1660.                                 a = a + 1
  1661.                                
  1662.                                 if a == HeightA then break end
  1663.                                
  1664.                             end
  1665.                            
  1666.                         end
  1667.                        
  1668.                     end
  1669.                    
  1670.                 else
  1671.                    
  1672.                     if a == HeightA then break end
  1673.                    
  1674.                     if MName ~= nil and DEata ~= nil then
  1675.                        
  1676.                         Functions.printCentered(Monitor[0], a, Functions.PadString(MName.."| "..tostring(DEata), w-4))
  1677.                        
  1678.                         a = a + 1
  1679.                        
  1680.                         if a == HeightA then break end
  1681.                        
  1682.                     end
  1683.                    
  1684.                 end
  1685.                
  1686.             end
  1687.            
  1688.         else
  1689.            
  1690.             if a == HeightA then break end
  1691.            
  1692.             if Mame ~= nil and Deta ~= nil then
  1693.                
  1694.                 Functions.printCentered(Monitor[0], a, Functions.PadString(Mame.."| "..tostring(Deta), w-4))
  1695.                
  1696.                 a = a + 1
  1697.                
  1698.                 if a == HeightA then break end
  1699.                
  1700.             end
  1701.            
  1702.         end
  1703.        
  1704.     end
  1705.    
  1706.     a = a + 1
  1707.    
  1708.     Functions.printCentered(Monitor[0], a, " ")
  1709.    
  1710. end
  1711.  
  1712.  
  1713. function drawTurtleMovementsMenu()
  1714.    
  1715.     checkForTurtles()
  1716.    
  1717.     for i = 1, #Turtles do
  1718.        
  1719.         if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  1720.            
  1721.             Computer.Connection.ConnectedTurtle = Turtles[i]
  1722.            
  1723.         end
  1724.        
  1725.     end
  1726.    
  1727.     Monitor[0].clear()
  1728.     Monitor[0].setCursorPos(1,1)
  1729.    
  1730.     Monitor[0].write("Computer Name: "..Computer.System.ComputerName)
  1731.    
  1732.     local R = GetOrientNames(Computer.Connection.ConnectedTurtle.Cor.R)
  1733.    
  1734.     Functions.printQuart(Monitor[0], 3,"Turtle Name: "..Computer.Connection.ConnectedTurtle.Name)
  1735.     Functions.printQuart(Monitor[0], 4,"Facing: "..R)
  1736.     Functions.printQuart(Monitor[0], 5,"Cor: X: "..Computer.Connection.ConnectedTurtle.Cor.X.." Y: "..Computer.Connection.ConnectedTurtle.Cor.Y.." Z: "..Computer.Connection.ConnectedTurtle.Cor.Z)
  1737.    
  1738.     Functions.printThreeQuartNC(Monitor[0], 6, "Up: "..Computer.Connection.ConnectedTurtle.Inspect.Up.name)
  1739.     Functions.printThreeQuartNC(Monitor[0], 7, "Forward: "..Computer.Connection.ConnectedTurtle.Inspect.Forward.name)
  1740.     Functions.printThreeQuartNC(Monitor[0], 8, "Down: "..Computer.Connection.ConnectedTurtle.Inspect.Down.name)
  1741.    
  1742.     Functions.SetColors(Monitor[0], Color.White, Color.Black)
  1743.    
  1744.     Monitor[0].setCursorPos(1, h)
  1745.     Monitor[0].write("Press 'B' to go back.")
  1746.    
  1747.     Functions.SetColors(Monitor[0], Color.Black, Color.White)
  1748.    
  1749. end
  1750.  
  1751. function drawTurtleMovementsFrontend()
  1752.    
  1753.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) -1, ((nTurtleMovementsOption == 1) and string.format("%s%s",Functions.PadString("[ Attack",NameLen-1),"]") or Functions.PadString("  Attack",NameLen)))
  1754.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +0, ((nTurtleMovementsOption == 2) and string.format("%s%s",Functions.PadString("[ Dig",NameLen-1),"]") or Functions.PadString("  Dig",NameLen)))
  1755.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +1, ((nTurtleMovementsOption == 3) and string.format("%s%s",Functions.PadString("[ Suck",NameLen-1),"]") or Functions.PadString("  Suck",NameLen)))
  1756.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +2, ((nTurtleMovementsOption == 4) and string.format("%s%s",Functions.PadString("[ Drop",NameLen-1),"]") or Functions.PadString("  Drop",NameLen)))
  1757.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +3, ((nTurtleMovementsOption == 5) and string.format("%s%s",Functions.PadString("[ Place",NameLen-1),"]") or Functions.PadString("  Place",NameLen)))
  1758.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +4, ((nTurtleMovementsOption == 6) and string.format("%s%s",Functions.PadString("[ Go To",NameLen-1),"]") or Functions.PadString("  Go To",NameLen)))
  1759.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +5, ((nTurtleMovementsOption == 7) and string.format("%s%s",Functions.PadString("[ Go Home",NameLen-1),"]") or Functions.PadString("  Go Home",NameLen)))
  1760.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +6, ((nTurtleMovementsOption == 8) and string.format("%s%s",Functions.PadString("[ Turn Direction",NameLen-1),"]") or Functions.PadString("  Turn Direction",NameLen)))
  1761.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +7, ((nTurtleMovementsOption == 9) and string.format("%s%s",Functions.PadString("[ Empty Inventory",NameLen-1),"]") or Functions.PadString("  Empty Inventory",NameLen)))
  1762.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +8, ((nTurtleMovementsOption == 10) and string.format("%s%s",Functions.PadString("[ ",NameLen-1),"]") or Functions.PadString("  ",NameLen)))
  1763.    
  1764.     Button.onScreen()
  1765.    
  1766. end
  1767.  
  1768.  
  1769. function drawTurtleAttackFrontend()
  1770.    
  1771.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) -3, Functions.PadString("  ",NameLen))
  1772.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) -2, ((nTurtleAttackOption == 1) and string.format("%s%s",Functions.PadString("[ Forward",NameLen-1),"]") or Functions.PadString("  Forward",NameLen)))
  1773.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) -1, ((nTurtleAttackOption == 2) and string.format("%s%s",Functions.PadString("[ Up",NameLen-1),"]") or Functions.PadString("  Up",NameLen)))
  1774.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +0, ((nTurtleAttackOption == 3) and string.format("%s%s",Functions.PadString("[ Down",NameLen-1),"]") or Functions.PadString("  Down",NameLen)))
  1775.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +1, Functions.PadString("  ",NameLen))
  1776.    
  1777.     Button.onScreen()
  1778.    
  1779. end
  1780.  
  1781. function drawTurtleDigFrontend()
  1782.    
  1783.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) -2, Functions.PadString("  ",NameLen))
  1784.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) -1, ((nTurtleDigOption == 1) and string.format("%s%s",Functions.PadString("[ Forward",NameLen-1),"]") or Functions.PadString("  Forward",NameLen)))
  1785.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +0, ((nTurtleDigOption == 2) and string.format("%s%s",Functions.PadString("[ Up",NameLen-1),"]") or Functions.PadString("  Up",NameLen)))
  1786.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +1, ((nTurtleDigOption == 3) and string.format("%s%s",Functions.PadString("[ Down",NameLen-1),"]") or Functions.PadString("  Down",NameLen)))
  1787.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +2, Functions.PadString("  ",NameLen))
  1788.    
  1789.     Button.onScreen()
  1790.    
  1791. end
  1792.  
  1793. function drawTurtleSuckFrontend()
  1794.    
  1795.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) -1, Functions.PadString("  ",NameLen))
  1796.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +0, ((nTurtleSuckOption == 1) and string.format("%s%s",Functions.PadString("[ Forward",NameLen-1),"]") or Functions.PadString("  Forward",NameLen)))
  1797.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +1, ((nTurtleSuckOption == 2) and string.format("%s%s",Functions.PadString("[ Up",NameLen-1),"]") or Functions.PadString("  Up",NameLen)))
  1798.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +2, ((nTurtleSuckOption == 3) and string.format("%s%s",Functions.PadString("[ Down",NameLen-1),"]") or Functions.PadString("  Down",NameLen)))
  1799.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +3, Functions.PadString("  ",NameLen))
  1800.    
  1801.     Button.onScreen()
  1802.    
  1803. end
  1804.  
  1805. function drawTurtleDropFrontend()
  1806.    
  1807.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +0, Functions.PadString("  ",NameLen))
  1808.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +1, ((nTurtleDropOption == 1) and string.format("%s%s",Functions.PadString("[ Forward",NameLen-1),"]") or Functions.PadString("  Forward",NameLen)))
  1809.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +2, ((nTurtleDropOption == 2) and string.format("%s%s",Functions.PadString("[ Up",NameLen-1),"]") or Functions.adString("  Up",NameLen)))
  1810.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +3, ((nTurtleDropOption == 3) and string.format("%s%s",Functions.PadString("[ Down",NameLen-1),"]") or Functions.PadString("  Down",NameLen)))
  1811.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +4, Functions.PadString("  ",NameLen))
  1812.    
  1813.     Button.onScreen()
  1814.    
  1815. end
  1816.  
  1817. function drawTurtlePlaceFrontend()
  1818.    
  1819.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +1, Functions.PadString("  ",NameLen))
  1820.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +2, ((nTurtlePlaceOption == 1) and string.format("%s%s",Functions.PadString("[ Forward",NameLen-1),"]") or Functions.PadString("  Forward",NameLen)))
  1821.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +3, ((nTurtlePlaceOption == 2) and string.format("%s%s",Functions.PadString("[ Up",NameLen-1),"]") or Functions.PadString("  Up",NameLen)))
  1822.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +4, ((nTurtlePlaceOption == 3) and string.format("%s%s",Functions.PadString("[ Down",NameLen-1),"]") or Functions.PadString("  Down",NameLen)))
  1823.     Functions.printThreeQuart(Monitor[0], math.floor(h/2) +5, Functions.PadString("  ",NameLen))
  1824.    
  1825.     Button.onScreen()
  1826.    
  1827. end
  1828.  
  1829.  
  1830. function drawTurtleProgramsMenu()
  1831.    
  1832.     Monitor[0].clear()
  1833.     Monitor[0].setCursorPos(1, 1)
  1834.     Monitor[0].write("Name: "..Computer.System.ComputerName)
  1835.    
  1836.     Monitor[0].setCursorPos(w-(NameLen+3), 2)
  1837.    
  1838.     if not(Computer.System.Nether) then
  1839.        
  1840.         if nTurtleProgramsOption == 1 then
  1841.            
  1842.             Monitor[0].write("Quarry")
  1843.            
  1844.         elseif nTurtleProgramsOption == 2 then
  1845.        
  1846.             Monitor[0].write("Tunner 3 By 3")
  1847.            
  1848.         elseif nTurtleProgramsOption == 3 then
  1849.            
  1850.             Monitor[0].write("3D Paint Pro")
  1851.            
  1852.         elseif nTurtleProgramsOption == 4 then
  1853.            
  1854.             Monitor[0].write("Farm")
  1855.            
  1856.         elseif nTurtleProgramsOption == 5 then
  1857.            
  1858.             Monitor[0].write("TreeFarm")
  1859.            
  1860.         else
  1861.            
  1862.         end
  1863.        
  1864.     else
  1865.        
  1866.         if nTurtleProgramsOption == 1 then
  1867.            
  1868.             Monitor[0].write("Quarry")
  1869.            
  1870.         elseif nTurtleProgramsOption == 2 then
  1871.        
  1872.             Monitor[0].write("Tunner 3 By 3")
  1873.            
  1874.         elseif nTurtleProgramsOption == 3 then
  1875.            
  1876.             Monitor[0].write("3D Paint Pro")
  1877.            
  1878.         else
  1879.            
  1880.         end
  1881.        
  1882.     end
  1883.    
  1884.     Functions.SetColors(Monitor[0], Color.White, Color.Black)
  1885.    
  1886.     Monitor[0].setCursorPos(1, h)
  1887.     Monitor[0].write("Press 'B' to go back.")
  1888.    
  1889.     Functions.SetColors(Monitor[0], Color.Black, Color.White)
  1890.    
  1891. end
  1892.  
  1893. function drawTurtleProgramsFrontend()
  1894.    
  1895.     Functions.printCentered(Monitor[0], math.floor(h/2) -3, Functions.PadString("  Program's Menu",NameLen))
  1896.    
  1897.     if not(Computer.System.Nether) then
  1898.        
  1899.         Functions.printCentered(Monitor[0], math.floor(h/2) -1, ((nTurtleProgramsOption == 1) and string.format("%s%s",Functions.PadString("[ Quarry",NameLen-1),"]") or Functions.PadString("  Quarry",NameLen)))
  1900.         Functions.printCentered(Monitor[0], math.floor(h/2) +0, ((nTurtleProgramsOption == 2) and string.format("%s%s",Functions.PadString("[ Tunner 3 By 3",NameLen-1),"]") or Functions.PadString("  Tunner 3 By 3",NameLen)))
  1901.         Functions.printCentered(Monitor[0], math.floor(h/2) +1, ((nTurtleProgramsOption == 3) and string.format("%s%s",Functions.PadString("[ 3D Paint Pro",NameLen-1),"]") or Functions.PadString("  3D Paint Pro",NameLen)))
  1902.         Functions.printCentered(Monitor[0], math.floor(h/2) +2, ((nTurtleProgramsOption == 4) and string.format("%s%s",Functions.PadString("[ Farm",NameLen-1),"]") or Functions.PadString("  Farm",NameLen)))
  1903.         Functions.printCentered(Monitor[0], math.floor(h/2) +3, ((nTurtleProgramsOption == 5) and string.format("%s%s",Functions.PadString("[ TreeFarm",NameLen-1),"]") or Functions.PadString("  TreeFarm",NameLen)))
  1904.        
  1905.     else
  1906.        
  1907.         Functions.printCentered(Monitor[0], math.floor(h/2) -1, ((nTurtleProgramsOption == 1) and string.format("%s%s",Functions.PadString("[ Quarry",NameLen-1),"]") or Functions.PadString("  Quarry",NameLen)))
  1908.         Functions.printCentered(Monitor[0], math.floor(h/2) +0, ((nTurtleProgramsOption == 2) and string.format("%s%s",Functions.PadString("[ Tunner 3 By 3",NameLen-1),"]") or Functions.PadString("  Tunner 3 By 3",NameLen)))
  1909.         Functions.printCentered(Monitor[0], math.floor(h/2) +1, ((nTurtleProgramsOption == 3) and string.format("%s%s",Functions.PadString("[ 3D Paint Pro",NameLen-1),"]") or Functions.PadString("  3D Paint Pro",NameLen)))
  1910.        
  1911.     end
  1912.    
  1913. end
  1914.  
  1915.  
  1916. function MoveMentOption()
  1917.    
  1918.     if MButtonn and Computer.Connection.ConnectedTurtle.Status then
  1919.        
  1920.         MButtonn = false
  1921.        
  1922.     elseif not(MButtonn) and Computer.Connection.ConnectedTurtle.Status then
  1923.        
  1924.         MButtonn = true
  1925.        
  1926.     end
  1927.    
  1928.     sleep(0.5)
  1929.    
  1930.     MMenuButton.toggleButton("M")
  1931.    
  1932. end
  1933.  
  1934. function TurtleInfo()
  1935.    
  1936.     if nMonitorOption == 1 then
  1937.        
  1938.         nMonitorOption = 0
  1939.         ButtonInfo = false
  1940.        
  1941.     else
  1942.        
  1943.         nMonitorOption = 1
  1944.         ButtonInfo = true
  1945.        
  1946.     end
  1947.    
  1948.     MMenuButton.toggleButton("Info")
  1949.    
  1950.     if ButtonInventory then
  1951.        
  1952.         MMenuButton.toggleButton("Inventory")
  1953.         ButtonInventory = false
  1954.        
  1955.     end
  1956.    
  1957.     if ButtonQuarry2 then
  1958.        
  1959.         MMenuButton.toggleButton("Strip Mine")
  1960.         ButtonQuarry2 = false
  1961.        
  1962.     end
  1963.    
  1964. end
  1965.  
  1966. function InventoryInfo()
  1967.    
  1968.     if nMonitorOption == 2 then
  1969.        
  1970.         nMonitorOption = 0
  1971.         ButtonInventory = false
  1972.        
  1973.     else
  1974.        
  1975.         nMonitorOption = 2
  1976.         ButtonInventory = true
  1977.        
  1978.     end
  1979.    
  1980.     MMenuButton.toggleButton("Inventory")
  1981.    
  1982.     if ButtonInfo then
  1983.        
  1984.         MMenuButton.toggleButton("Info")
  1985.         ButtonInfo = false
  1986.        
  1987.     end
  1988.    
  1989.     if ButtonQuarry2 then
  1990.        
  1991.         MMenuButton.toggleButton("Strip Mine")
  1992.         ButtonQuarry2 = false
  1993.        
  1994.     end
  1995.    
  1996. end
  1997.  
  1998. function Quarry2()
  1999.    
  2000.     if nMonitorOption == 3 then
  2001.        
  2002.         nMonitorOption = 0
  2003.         ButtonQuarry2 = false
  2004.        
  2005.     else
  2006.        
  2007.         nMonitorOption = 3
  2008.         ButtonQuarry2 = true
  2009.        
  2010.     end
  2011.    
  2012.     MMenuButton.toggleButton("Strip Mine")
  2013.    
  2014.     if ButtonInventory then
  2015.        
  2016.         MMenuButton.toggleButton("Inventory")
  2017.         ButtonInventory = false
  2018.        
  2019.     end
  2020.    
  2021.     if ButtonInfo then
  2022.        
  2023.         MMenuButton.toggleButton("Info")
  2024.         ButtonInfo = false
  2025.        
  2026.     end
  2027.        
  2028.    
  2029. end
  2030.  
  2031. function ClickedInventoryButton(Slot)
  2032.    
  2033.     if Computer.Connection.ConnectedTurtle.Status then
  2034.        
  2035.         local Data = {What = "Command", Command = "/SelectSlot/", Data = tonumber(Slot)}
  2036.        
  2037.         WModem.transmit(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2038.        
  2039.         nMonitorTurtleInventoryOption = tonumber(Slot)
  2040.         InventoryButton[nMonitorTurtleInventoryOption] = true
  2041.        
  2042.         sleep(1)
  2043.        
  2044.         checkForTurtles()
  2045.        
  2046.         for i = 1, #Turtles do
  2047.            
  2048.             if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  2049.                
  2050.                 Computer.Connection.ConnectedTurtle = Turtles[i]
  2051.                
  2052.             end
  2053.            
  2054.         end
  2055.        
  2056.         for i = 1, 16 do
  2057.            
  2058.             if InventoryButton[i] == true and i ~= nMonitorTurtleInventoryOption then
  2059.                 MINVButton.toggleButton(tostring(i))
  2060.                 InventoryButton[i] = false
  2061.             end
  2062.            
  2063.             if Computer.Connection.ConnectedTurtle.Slot == nil then
  2064.                 Computer.Connection.ConnectedTurtle.Slot = {}
  2065.             end
  2066.            
  2067.             if Computer.Connection.ConnectedTurtle.Slot[i] == nil then
  2068.                
  2069.                 Computer.Connection.ConnectedTurtle.Slot[i] = { Count = 0, Data = { name = ":Nothing" }}
  2070.                
  2071.             else
  2072.                
  2073.                 if Computer.Connection.ConnectedTurtle.Slot[i].Count == nil then
  2074.                    
  2075.                     Computer.Connection.ConnectedTurtle.Slot[i].Count = 0
  2076.                    
  2077.                 end
  2078.                
  2079.                 if Computer.Connection.ConnectedTurtle.Slot[i].Data == nil then
  2080.                    
  2081.                     Computer.Connection.ConnectedTurtle.Slot[i].Data = { name = ":Nothing" }
  2082.                    
  2083.                 end
  2084.                
  2085.             end
  2086.            
  2087.         end
  2088.        
  2089.     end
  2090.    
  2091. end
  2092.  
  2093. function Edit(What)
  2094.    
  2095.     Enter = false
  2096.     Number = "0  "
  2097.     local Wich
  2098.     local ax, ay
  2099.    
  2100.     if What == "XEdit" then
  2101.        
  2102.         ax, ay = 60, 6
  2103.         Wich = "X"
  2104.        
  2105.     elseif What == "ZEdit" then
  2106.        
  2107.         ax, ay = 60, 9
  2108.         Wich = "Z"
  2109.        
  2110.     elseif What == "YEdit" then
  2111.        
  2112.         ax, ay = 60, 13
  2113.         Wich = "Y"
  2114.        
  2115.     elseif What == "LayerEdit" then
  2116.        
  2117.         ax, ay = 60, 13
  2118.         Wich = "Layer"
  2119.        
  2120.     elseif What == "RadiusEdit" then
  2121.        
  2122.         ax, ay = 60, 17
  2123.         Wich = "Radius"
  2124.        
  2125.     end
  2126.    
  2127.     MExtraButton.clearButtons()
  2128.    
  2129.     MExtraButton.setButton("1", DoEdit, 68, 68 + 4, 5 , 5 + 4, true, "1")
  2130.     MExtraButton.setButton("2", DoEdit, 68 + 6, 68 + 10, 5, 5 + 4, true, "2")
  2131.     MExtraButton.setButton("3", DoEdit, 68 + 12, 68 + 16, 5, 5 + 4, true, "3")
  2132.     MExtraButton.setButton("4", DoEdit, 68, 68 + 4, 5 + 6, 5 + 10, true, "4")
  2133.     MExtraButton.setButton("5", DoEdit, 68 + 6, 68 + 10, 5 + 6, 5 + 10, true, "5")
  2134.     MExtraButton.setButton("6", DoEdit, 68 + 12, 68 + 16, 5 + 6, 5 + 10, true, "6")
  2135.     MExtraButton.setButton("7", DoEdit, 68, 68 + 4, 5 + 12, 5 + 16, true, "7")
  2136.     MExtraButton.setButton("8", DoEdit, 68 + 6, 68 + 10, 5 + 12, 5 + 16, true, "8")
  2137.     MExtraButton.setButton("9", DoEdit, 68 + 12, 68 + 16, 5 + 12, 5 + 16, true, "9")
  2138.     MExtraButton.setButton("R", DoEdit, 68, 68 + 4, 5 + 18, 5 + 22, true, "R")
  2139.     MExtraButton.setButton("0", DoEdit, 68 + 6, 68 + 10, 5 + 18, 5 + 22, true, "0")
  2140.     MExtraButton.setButton("OK", DoEdit, 68 + 12, 68 + 16, 5 + 18, 5 + 22, true, {What = "OK", W = Wich})
  2141.     MExtraButton.setButton("-", DoEdit, 68 + 6, 68 + 10, 5 + 24, 5 + 28, true, "-")
  2142.    
  2143.     while not(Enter) do
  2144.        
  2145.         MExtraButton.onScreen()
  2146.        
  2147.         Monitor[1].setCursorPos(ax, ay)
  2148.         Monitor[1].write(Number)
  2149.        
  2150.         local Event, p1, p2, p3 = System.pullEvent("monitor_touch")
  2151.        
  2152.         if Event == "monitor_touch" then
  2153.            
  2154.             local Button, MX, MY = p1, p2, p3
  2155.        
  2156.             MExtraButton.buttonPressed(MX, MY)
  2157.            
  2158.         end
  2159.        
  2160.     end
  2161.    
  2162.     Enter = false
  2163.    
  2164. end
  2165.  
  2166. function DoEdit(What)
  2167.    
  2168.     if type(What) == "string" then
  2169.        
  2170.         if What == "R" then
  2171.            
  2172.             Number = "0  "
  2173.            
  2174.         else
  2175.            
  2176.             if Number == "0  " then
  2177.                
  2178.                 Number = ""
  2179.                
  2180.             end
  2181.            
  2182.             Number = Number..What
  2183.            
  2184.         end
  2185.        
  2186.     elseif type(What) == "table" then
  2187.        
  2188.         if What.What == "OK" then
  2189.            
  2190.             if Number ~= "0  " then
  2191.                
  2192.                 if What.W == "X" then
  2193.                    
  2194.                     GoToX = tonumber(Number)
  2195.                    
  2196.                 elseif What.W == "Z" then
  2197.                    
  2198.                     GoToZ = tonumber(Number)
  2199.                    
  2200.                 elseif What.W == "Y" then
  2201.                    
  2202.                     if tonumber(Number) < 251 and tonumber(Number) > 4 then
  2203.                        
  2204.                         GoToY = tonumber(Number)
  2205.                        
  2206.                     else
  2207.                        
  2208.                         if tonumber(Number) > 250 then
  2209.                            
  2210.                             GoToY = 250
  2211.                            
  2212.                         elseif tonumber(Number) < 5 then
  2213.                            
  2214.                             GoToY = 5
  2215.                            
  2216.                         end
  2217.                        
  2218.                     end
  2219.                    
  2220.                 elseif What.W == "Layer" then
  2221.                    
  2222.                     if tonumber(Number) < 251 and tonumber(Number) > 4 then
  2223.                        
  2224.                         Layer = tonumber(Number)
  2225.                        
  2226.                     else
  2227.                        
  2228.                         if tonumber(Number) > 250 then
  2229.                            
  2230.                             Layer = 250
  2231.                            
  2232.                         elseif tonumber(Number) < 5 then
  2233.                            
  2234.                             Layer = 5
  2235.                            
  2236.                         end
  2237.                        
  2238.                     end
  2239.                    
  2240.                 elseif What.W == "Radius" then
  2241.                    
  2242.                     if tonumber(Number) <= MaxRadius and tonumber(Number) >= MinRadius then
  2243.                        
  2244.                         if (tonumber(Number)%2) == 1 then
  2245.                            
  2246.                             Radius = tonumber(Number)
  2247.                            
  2248.                         else
  2249.                            
  2250.                             Radius = tonumber(Number) + 1
  2251.                            
  2252.                         end
  2253.                        
  2254.                     else
  2255.                        
  2256.                         if tonumber(Number) > MaxRadius then
  2257.                            
  2258.                             Radius = MaxRadius
  2259.                            
  2260.                         elseif tonumber(Number) < MinRadius then
  2261.                            
  2262.                             Radius = MinRadius
  2263.                            
  2264.                         end
  2265.                        
  2266.                     end
  2267.                    
  2268.                 end
  2269.                
  2270.             end
  2271.            
  2272.             Enter = true
  2273.            
  2274.         end
  2275.        
  2276.     end
  2277.    
  2278. end
  2279.  
  2280. function Quarry(What)
  2281.    
  2282.     if What == "Reset" then
  2283.        
  2284.         GoToX, GoToY, GoToZ, Radius, Layer = Computer.Connection.ConnectedTurtle.Cor.X, Computer.Connection.ConnectedTurtle.Cor.Y, Computer.Connection.ConnectedTurtle.Cor.Z, 3, 6
  2285.        
  2286.     elseif What == "XMin" then
  2287.        
  2288.         GoToX = GoToX - 1
  2289.        
  2290.     elseif What == "XPlus" then
  2291.        
  2292.         GoToX = GoToX + 1
  2293.        
  2294.     elseif What == "ZMin" then
  2295.        
  2296.         GoToZ = GoToZ - 1
  2297.        
  2298.     elseif What == "ZPlus" then
  2299.        
  2300.         GoToZ = GoToZ + 1
  2301.        
  2302.     elseif What == "LayerMin" then
  2303.        
  2304.         if Layer > 5 then
  2305.            
  2306.             Layer = Layer - 1
  2307.            
  2308.         end
  2309.        
  2310.     elseif What == "LayerPlus" then
  2311.        
  2312.         if Layer < 250 then
  2313.            
  2314.             Layer = Layer + 1
  2315.            
  2316.         end
  2317.        
  2318.     elseif What == "RadiusMin" then
  2319.        
  2320.         if Radius > MinRadius then
  2321.            
  2322.             Radius = Radius - 2
  2323.            
  2324.         end
  2325.        
  2326.     elseif What == "RadiusPlus" then
  2327.        
  2328.         if Radius < MaxRadius then
  2329.            
  2330.             Radius = Radius + 2
  2331.            
  2332.         end
  2333.        
  2334.     elseif What == "Start" then
  2335.        
  2336.         FreeGroupT = {}
  2337.         local oldname = {}
  2338.        
  2339.         checkForTurtles()
  2340.        
  2341.         for i = 1, #Turtles do
  2342.            
  2343.             if Turtles[i].GroupState and Turtles[i].Status then
  2344.                
  2345.                 table.insert(FreeGroupT, Turtles[i])
  2346.                 sleep(0.5)
  2347.                
  2348.             end
  2349.            
  2350.         end
  2351.        
  2352.         SendInfo(FreeGroupT[1].Id, "Function", "GTH", Computer.System.Modem.OwnID)
  2353.        
  2354.         local Event, p1, p2, p3, p4, p5 = System.pullEvent("modem_message")
  2355.        
  2356.         TravelHeight = UnPack(p4)
  2357.        
  2358.         sleep(1)
  2359.        
  2360.         for i = 1, #FreeGroupT do
  2361.            
  2362.             SendInfo(FreeGroupT[i].Id, "Function", "StripMine")
  2363.             sleep(1)
  2364.             oldname[i] = FreeGroupT[i].Name
  2365.             SendInfo(FreeGroupT[i].Id, "Function", "NS", FreeGroupT[i].Name.."Strip Mine")
  2366.             sleep(1)
  2367.             SendInfo(FreeGroupT[i].Id, "Function", "GT", Tool.PickAxe)
  2368.            
  2369.         end
  2370.        
  2371.         sleep(10)
  2372.        
  2373.         local x, y = Monitor[0].getSize()
  2374.         local mx, my = Monitor[1].getSize()
  2375.        
  2376.         Monitor[0].clear()
  2377.         Monitor[1].clear()
  2378.         Monitor[0].setCursorPos(1,math.floor(y/2)+0)
  2379.         Monitor[1].setCursorPos(1,math.floor(my/2)+0)
  2380.        
  2381.         Monitor[0].write("GoTo Qaurry")
  2382.         Monitor[1].write("GoTo Quarry")
  2383.        
  2384.         local Cor = {X = GoToX, Y = TravelHeight, Z = GoToZ}
  2385.        
  2386.         for i = 1, #FreeGroupT do
  2387.            
  2388.             SendInfo(FreeGroupT[i].Id, "Function", "GoTo", Cor)
  2389.             sleep(1)
  2390.            
  2391.         end
  2392.        
  2393.         Cor = {X = GoToX, Y = Layer, Z = GoToZ}
  2394.        
  2395.         for i = 1, #FreeGroupT do
  2396.            
  2397.             local Event, p1, p2, p3, p4, p5 = System.pullEvent("modem_message")
  2398.             SendInfo(p3, "Function", "MQ", Cor)
  2399.            
  2400.         end
  2401.        
  2402.         sleep(1)
  2403.        
  2404.         local Beam = math.floor((Radius - 1) / 2)
  2405.         local RadiusA = Radius
  2406.        
  2407.         Cor.Z = Cor.Z + Beam
  2408.  
  2409.         local done = false
  2410.        
  2411.         for i = 1, #FreeGroupT do
  2412.            
  2413.             local yes = false
  2414.             local Id
  2415.            
  2416.             while not(yes) do
  2417.                
  2418.                 local Event, p1, p2, p3, p4, p5 = System.pullEvent("modem_message")
  2419.                 Id = p3
  2420.                
  2421.                 if not(done) then
  2422.                    
  2423.                     done = {}
  2424.                     table.insert(done, p3)
  2425.                     yes = true
  2426.                    
  2427.                 else
  2428.                    
  2429.                     local found = false
  2430.                    
  2431.                     for ii = 1, #done do
  2432.                        
  2433.                         if p3 == done[ii] then
  2434.                            
  2435.                             found = true
  2436.                             break
  2437.                            
  2438.                         end
  2439.                        
  2440.                     end
  2441.                    
  2442.                     if not(found) then
  2443.                        
  2444.                         table.insert(done, p3)
  2445.                         yes = true
  2446.                        
  2447.                     end
  2448.                    
  2449.                 end
  2450.                
  2451.             end
  2452.            
  2453.             SendInfo(Id, "Function", "GoTo", Cor)
  2454.            
  2455.             if RadiusA > 0 then
  2456.                
  2457.                 RadiusA = RadiusA - 3
  2458.                 Cor.Z = Cor.Z - 3
  2459.                
  2460.             end
  2461.            
  2462.         end
  2463.        
  2464.         local Event, p1, p2, p3, p4, p5 = System.pullEvent("modem_message")
  2465.        
  2466.         for i = 1, #FreeGroupT do
  2467.            
  2468.             SendInfo(FreeGroupT[i].Id, "Function", "TD", 1)
  2469.            
  2470.         end
  2471.        
  2472.         UpDaTe()
  2473.        
  2474.         for i = 1, #FreeGroupT do
  2475.            
  2476.             SendInfo(FreeGroupT[i].Id, "Function", "TD", 1)
  2477.            
  2478.         end
  2479.        
  2480.         sleep(2)
  2481.        
  2482.         local On = true
  2483.        
  2484.         while On do
  2485.            
  2486.             Monitor[0].setCursorPos(1,math.floor(y/2)+0)
  2487.             Monitor[1].setCursorPos(1,math.floor(my/2)+0)
  2488.             Monitor[0].clearLine()
  2489.             Monitor[1].clearLine()
  2490.             Monitor[0].write("Getting Information")
  2491.             Monitor[1].write("Getting Information")
  2492.            
  2493.             local FunctionSend = {}
  2494.            
  2495.             table.insert(FunctionSend, "A")
  2496.            
  2497.             for i = 1, Beam do
  2498.                
  2499.                 table.insert(FunctionSend, "DFW")
  2500.                
  2501.                 table.insert(FunctionSend, "A")
  2502.                
  2503.                 for a = 1, 2 do
  2504.                    
  2505.                     table.insert(FunctionSend, "D")
  2506.                    
  2507.                 end
  2508.                
  2509.                 table.insert(FunctionSend, "A")
  2510.                
  2511.             end
  2512.            
  2513.             for i = 1, Beam do
  2514.                
  2515.                 table.insert(FunctionSend, "S")
  2516.                
  2517.             end
  2518.            
  2519.             for i = 1, 2 do
  2520.                
  2521.                 table.insert(FunctionSend, "D")
  2522.                
  2523.             end
  2524.            
  2525.             for i = 1, Beam do
  2526.                
  2527.                 table.insert(FunctionSend, "DFW")
  2528.                
  2529.                 table.insert(FunctionSend, "A")
  2530.                
  2531.                 for a = 1, 2 do
  2532.                    
  2533.                     table.insert(FunctionSend, "D")
  2534.                    
  2535.                 end
  2536.                
  2537.                 table.insert(FunctionSend, "A")
  2538.                
  2539.             end
  2540.            
  2541.             for i = 1, Beam do
  2542.                
  2543.                 table.insert(FunctionSend, "S")
  2544.                
  2545.             end
  2546.            
  2547.             table.insert(FunctionSend, "A")
  2548.            
  2549.             table.insert(FunctionSend, "CINV")
  2550.            
  2551.             table.insert(FunctionSend, "Fuel")
  2552.            
  2553.             Monitor[0].setCursorPos(1,math.floor(y/2)+0)
  2554.             Monitor[1].setCursorPos(1,math.floor(my/2)+0)
  2555.             Monitor[0].clearLine()
  2556.             Monitor[1].clearLine()
  2557.             Monitor[0].write("Doing Qaurry on Layer: "..Layer.."  Radius: "..Radius)
  2558.             Monitor[1].write("Doing Quarry on Layer: "..Layer.."  Radius: "..Radius)
  2559.            
  2560.             for i = 1, #FreeGroupT do
  2561.                
  2562.                 SendInfo(FreeGroupT[i].Id, "Function", FunctionSend)
  2563.                 sleep(0.5)
  2564.                
  2565.             end
  2566.            
  2567.             UpDaTe()
  2568.            
  2569.             if RadiusA > 0 then
  2570.                
  2571.                 for i = 1, #FreeGroupT do
  2572.                    
  2573.                     SendInfo(FreeGroupT[i].Id, "Function", "GoTo", Cor)
  2574.                    
  2575.                     RadiusA = RadiusA - 3
  2576.                     Cor.Z = Cor.Z - 3
  2577.                    
  2578.                 end
  2579.                
  2580.                 for i = 1, #FreeGroupT do
  2581.                    
  2582.                     local Event, p1, p2, p3, p4, p5 = System.pullEvent("modem_message")
  2583.                     SendInfo(p3, "Function", "TD", 1)
  2584.                    
  2585.                 end
  2586.                
  2587.             else
  2588.                
  2589.                 On = false
  2590.                
  2591.             end
  2592.            
  2593.             sleep(1)
  2594.            
  2595.         end
  2596.        
  2597.         Monitor[0].setCursorPos(1,math.floor(y/2)+0)
  2598.         Monitor[1].setCursorPos(1,math.floor(my/2)+0)
  2599.         Monitor[0].clearLine()
  2600.         Monitor[1].clearLine()
  2601.         Monitor[0].write("Done, Going Home")
  2602.         Monitor[1].write("Done, Going Home")
  2603.        
  2604.         Cor = {X = GoToX, Y = Layer, Z = GoToZ}
  2605.        
  2606.         for i = 1, #FreeGroupT do
  2607.            
  2608.             SendInfo(FreeGroupT[i].Id, "Function", "GoTo", Cor)
  2609.            
  2610.         end
  2611.        
  2612.         for i = 1, #FreeGroupT do
  2613.            
  2614.             local Event, p1, p2, p3, p4, p5 = System.pullEvent("modem_message")
  2615.             SendInfo(FreeGroupT[i].Id, "Function", "Home")
  2616.            
  2617.         end
  2618.        
  2619.         UpDaTe()
  2620.        
  2621.         for i = 1, #FreeGroupT do
  2622.            
  2623.             SendInfo(FreeGroupT[i].Id, "Function", "INV")
  2624.            
  2625.         end
  2626.        
  2627.         UpDaTe()
  2628.        
  2629.         for i = 1, #FreeGroupT do
  2630.            
  2631.             SendInfo(FreeGroupT[i].Id, "Function", "PTA")
  2632.            
  2633.         end
  2634.        
  2635.         UpDaTe()
  2636.        
  2637.         for i = 1, #FreeGroupT do
  2638.            
  2639.             SendInfo(FreeGroupT[i].Id, "Function", "NS", oldname[i])
  2640.            
  2641.         end
  2642.        
  2643.         UpDaTe()
  2644.        
  2645.         for i = 1, #FreeGroupT do
  2646.            
  2647.             SendInfo(FreeGroupT[i].Id, "Function", "StripMineDone")
  2648.            
  2649.         end
  2650.        
  2651.     end
  2652.    
  2653. end
  2654.  
  2655. local MINVButtonShow = false
  2656.  
  2657. function Do(What)
  2658.    
  2659.     if What == "EmptyInventory" then
  2660.        
  2661.         if not(MINVButtonShow) then
  2662.            
  2663.             MINVButton.setButtonShow("Slot", true)
  2664.             MINVButton.setButtonShow("All", true)
  2665.             MINVButtonShow = true
  2666.            
  2667.         else
  2668.            
  2669.             MINVButton.setButtonShow("Slot", false)
  2670.             MINVButton.setButtonShow("All", false)
  2671.             MINVButtonShow = false
  2672.            
  2673.         end
  2674.        
  2675.     elseif What == "EmptyInventorySlot" then
  2676.        
  2677.         local Data = {What = "Function", Function = "DRD", Data = 64}
  2678.        
  2679.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2680.        
  2681.         sleep (0.5)
  2682.        
  2683.         MINVButton.toggleButton("Slot")
  2684.         MINVButton.setButtonShow("Slot", false)
  2685.         MINVButton.setButtonShow("All", false)
  2686.         MINVButtonShow = false
  2687.        
  2688.         MINVButton.toggleButton("Empty")
  2689.        
  2690.     elseif What == "EmptyInventoryAll" then
  2691.        
  2692.         local Data = {What = "Command", Command = "/EmptyInventory/"}
  2693.        
  2694.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2695.        
  2696.         sleep (0.5)
  2697.        
  2698.         MINVButton.toggleButton("All")
  2699.         MINVButton.setButtonShow("Slot", false)
  2700.         MINVButton.setButtonShow("All", false)
  2701.         MINVButtonShow = false
  2702.        
  2703.         MINVButton.toggleButton("Empty")
  2704.        
  2705.     elseif What == "EquipLeft" then
  2706.        
  2707.         local Data = {What = "Command", Command = "/EqUip/", Data = "left"}
  2708.        
  2709.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2710.        
  2711.         sleep (0.5)
  2712.        
  2713.         MINVButton.toggleButton("Equip")
  2714.        
  2715.     elseif What == "Fuel" then
  2716.        
  2717.         local Data = {What = "Function", Function = "Fuel"}
  2718.        
  2719.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2720.        
  2721.         sleep (0.5)
  2722.        
  2723.         MINVButton.toggleButton("Refuel")
  2724.        
  2725.     elseif What == "Transfer" then
  2726.        
  2727.         local mx, my = Monitor[1].getSize()
  2728.        
  2729.         local BottomMonitor = my - 1
  2730.         local TopMonitor = 1 + 1
  2731.         local EndMonitor = mx + 1
  2732.         local BeginMonitor = 1 + 1
  2733.        
  2734.         MExtraButton.clearTable()
  2735.        
  2736.         MExtraButton.setButton("1", TransferTo, BeginMonitor + 35, BeginMonitor + 39, TopMonitor + 3, TopMonitor + 5, 1, true)
  2737.         MExtraButton.setButton("2", TransferTo, BeginMonitor + 41, BeginMonitor + 45, TopMonitor + 3, TopMonitor + 5, 2, true)
  2738.         MExtraButton.setButton("3", TransferTo, BeginMonitor + 47, BeginMonitor + 51, TopMonitor + 3, TopMonitor + 5, 3, true)
  2739.         MExtraButton.setButton("4", TransferTo, BeginMonitor + 53, BeginMonitor + 57, TopMonitor + 3, TopMonitor + 5, 4, true)
  2740.         MExtraButton.setButton("5", TransferTo, BeginMonitor + 35, BeginMonitor + 39, TopMonitor + 7, TopMonitor + 9, 5, true)
  2741.         MExtraButton.setButton("6", TransferTo, BeginMonitor + 41, BeginMonitor + 45, TopMonitor + 7, TopMonitor + 9, 6, true)
  2742.         MExtraButton.setButton("7", TransferTo, BeginMonitor + 47, BeginMonitor + 51, TopMonitor + 7, TopMonitor + 9, 7, true)
  2743.         MExtraButton.setButton("8", TransferTo, BeginMonitor + 53, BeginMonitor + 57, TopMonitor + 7, TopMonitor + 9, 8, true)
  2744.         MExtraButton.setButton("9", TransferTo, BeginMonitor + 35, BeginMonitor + 39, TopMonitor + 11, TopMonitor + 13, 9, true)
  2745.         MExtraButton.setButton("10", TransferTo, BeginMonitor + 41, BeginMonitor + 45, TopMonitor + 11, TopMonitor + 13, 10, true)
  2746.         MExtraButton.setButton("11", TransferTo, BeginMonitor + 47, BeginMonitor + 51, TopMonitor + 11, TopMonitor + 13, 11, true)
  2747.         MExtraButton.setButton("12", TransferTo, BeginMonitor + 53, BeginMonitor + 57, TopMonitor + 11, TopMonitor + 13, 12, true)
  2748.         MExtraButton.setButton("13", TransferTo, BeginMonitor + 35, BeginMonitor + 39, TopMonitor + 15, TopMonitor + 17, 13, true)
  2749.         MExtraButton.setButton("14", TransferTo, BeginMonitor + 41, BeginMonitor + 45, TopMonitor + 15, TopMonitor + 17, 14, true)
  2750.         MExtraButton.setButton("15", TransferTo, BeginMonitor + 47, BeginMonitor + 51, TopMonitor + 15, TopMonitor + 17, 15, true)
  2751.         MExtraButton.setButton("16", TransferTo, BeginMonitor + 53, BeginMonitor + 57, TopMonitor + 15, TopMonitor + 17, 16, true)
  2752.        
  2753.         MExtraButton.onScreen()
  2754.        
  2755.         local Event, p1, p2, p3 = System.pullEvent("monitor_touch")
  2756.        
  2757.         if Event == "monitor_touch" then
  2758.            
  2759.             local Button, MX, MY = p1, p2, p3
  2760.        
  2761.             MExtraButton.buttonPressed(MX, MY)
  2762.            
  2763.         end
  2764.        
  2765.         sleep (0.5)
  2766.        
  2767.         MINVButton.toggleButton("Transfer")
  2768.        
  2769.     elseif What == "GoHome" then
  2770.        
  2771.         local Data = {What = "Command", Command = "/GoHome/"}
  2772.        
  2773.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2774.        
  2775.     elseif What == "GoTo" then
  2776.        
  2777.         GoToX, GoToY, GoToZ = Computer.Connection.ConnectedTurtle.Cor.X, Computer.Connection.ConnectedTurtle.Cor.Y, Computer.Connection.ConnectedTurtle.Cor.Z
  2778.         Enter = false
  2779.        
  2780.         while not(Enter) do
  2781.            
  2782.             local mw, mh = Monitor[1].getSize()
  2783.            
  2784.             MExtraButton.clearButtons()
  2785.            
  2786.             MExtraButton.setButton("X Up", Change, 10, 16, (mh/2)-5, (mh/2)-3, true, "X Up")
  2787.             MExtraButton.setButton("X Down", Change, 10, 16, (mh/2)+3, (mh/2)+5, true, "X Down")
  2788.             MExtraButton.setButton("X Edit", Edit, 10, 16, (mh/2)+6, (mh/2)+8, true, "XEdit")
  2789.            
  2790.             MExtraButton.setButton("Y Up", Change, 17, 23, (mh/2)-5, (mh/2)-3, true, "Y Up")
  2791.             MExtraButton.setButton("Y Down", Change, 17, 23, (mh/2)+3, (mh/2)+5, true, "Y Down")
  2792.             MExtraButton.setButton("Y Edit", Edit, 17, 23, (mh/2)+6, (mh/2)+8, true, "YEdit")
  2793.            
  2794.             MExtraButton.setButton("Z Up", Change, 24, 30, (mh/2)-5, (mh/2)-3, true, "Z Up")
  2795.             MExtraButton.setButton("Z Down", Change, 24, 30, (mh/2)+3, (mh/2)+5, true, "Z Down")
  2796.             MExtraButton.setButton("Z Edit", Edit, 24, 30, (mh/2)+6, (mh/2)+8, true, "ZEdit")
  2797.            
  2798.             MExtraButton.setButton("Enter", Change, 32, 37, (mh/2)-1, (mh/2)+1, true, "Enter")
  2799.            
  2800.             Monitor[1].clear()
  2801.            
  2802.             MExtraButton.onScreen()
  2803.            
  2804.             Monitor[1].setCursorPos(1, mh/2)
  2805.             Monitor[1].write("Goto: X: ".. GoToX.." Y: "..GoToY.." Z: "..GoToZ)
  2806.            
  2807.             local Event, p1, p2, p3 = System.pullEvent("monitor_touch")
  2808.            
  2809.             if Event == "monitor_touch" then
  2810.                
  2811.                 local Button, MX, MY = p1, p2, p3
  2812.            
  2813.                 MExtraButton.buttonPressed(MX, MY)
  2814.                
  2815.             end
  2816.            
  2817.         end
  2818.        
  2819.         local Cor = {X = GoToX, Y = GoToY, Z = GoToZ}
  2820.         local Data = {What = "Command", Command = "/GoTo/", Data = Cor}
  2821.        
  2822.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2823.        
  2824.     end
  2825.    
  2826. end
  2827.  
  2828. function TransferTo(What)
  2829.    
  2830.     local Data = {What = "Command", Command = "/TransferTo/", Data = tonumber(What)}
  2831.    
  2832.     WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2833.    
  2834. end
  2835.  
  2836. function Change(What)
  2837.    
  2838.     if What == "X Up" then
  2839.        
  2840.         GoToX = GoToX + 1
  2841.        
  2842.     elseif What == "X Down" then
  2843.        
  2844.         GoToX = GoToX - 1
  2845.        
  2846.     elseif What == "Y Up" then
  2847.        
  2848.         if GoToY < 250 then
  2849.            
  2850.             GoToY = GoToY + 1
  2851.            
  2852.         end
  2853.        
  2854.     elseif What == "Y Down" then
  2855.        
  2856.         if GoToY > 5 then
  2857.            
  2858.             GoToY = GoToY - 1
  2859.            
  2860.         end
  2861.        
  2862.     elseif What == "Z Up" then
  2863.        
  2864.         GoToZ = GoToZ + 1
  2865.        
  2866.     elseif What == "Z Down" then
  2867.        
  2868.         GoToZ = GoToZ - 1
  2869.        
  2870.     elseif What == "Enter" then
  2871.        
  2872.         Enter = true
  2873.        
  2874.     end
  2875.    
  2876. end
  2877.  
  2878. function GetOrientNames(R)
  2879.    
  2880.     if R == 1 then
  2881.         return "North"
  2882.     elseif R == 2 then
  2883.         return "East"
  2884.     elseif R == 3 then
  2885.         return "South"
  2886.     elseif R == 4 then
  2887.         return "West"
  2888.     end
  2889.    
  2890. end
  2891.  
  2892. function Move(What)
  2893.    
  2894.     if What == "up" then
  2895.        
  2896.         local Data = {What = "Function", Function = "R"}
  2897.        
  2898.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2899.        
  2900.     elseif What == "down" then
  2901.        
  2902.         local Data = {What = "Function", Function = "F"}
  2903.        
  2904.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2905.        
  2906.     elseif What == "forward" then
  2907.        
  2908.         local Data = {What = "Function", Function = "W"}
  2909.        
  2910.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2911.        
  2912.     elseif What == "back" then
  2913.        
  2914.         local Data = {What = "Function", Function = "S"}
  2915.        
  2916.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2917.        
  2918.     elseif What == "left" then
  2919.        
  2920.         local Data = {What = "Function", Function = "A"}
  2921.        
  2922.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2923.        
  2924.     elseif What == "right" then
  2925.        
  2926.         local Data = {What = "Function", Function = "D"}
  2927.        
  2928.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2929.        
  2930.     end
  2931.    
  2932. end
  2933.  
  2934. function Dig(What)
  2935.    
  2936.     if What == "up" then
  2937.        
  2938.         local Data = {What = "Function", Function = "DU"}
  2939.        
  2940.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2941.        
  2942.     elseif What == "forward" then
  2943.        
  2944.         local Data = {What = "Function", Function = "DF"}
  2945.        
  2946.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2947.        
  2948.     elseif What == "down" then
  2949.        
  2950.         local Data = {What = "Function", Function = "DD"}
  2951.        
  2952.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2953.        
  2954.     end
  2955.    
  2956. end
  2957.  
  2958. function Place(What)
  2959.    
  2960.     if What == "up" then
  2961.        
  2962.         local Data = {What = "Function", Function = "PU"}
  2963.        
  2964.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2965.        
  2966.     elseif What == "forward" then
  2967.        
  2968.         local Data = {What = "Function", Function = "PF"}
  2969.        
  2970.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2971.        
  2972.     elseif What == "down" then
  2973.        
  2974.         local Data = {What = "Function", Function = "PD"}
  2975.        
  2976.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2977.        
  2978.     end
  2979.    
  2980. end
  2981.  
  2982. function Suck(What)
  2983.    
  2984.     if What == "up" then
  2985.        
  2986.         local Data = {What = "Function", Function = "SU"}
  2987.        
  2988.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2989.        
  2990.     elseif What == "forward" then
  2991.        
  2992.         local Data = {What = "Function", Function = "SF"}
  2993.        
  2994.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  2995.        
  2996.     elseif What == "down" then
  2997.        
  2998.         local Data = {What = "Function", Function = "SD"}
  2999.        
  3000.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3001.        
  3002.     end
  3003.    
  3004. end
  3005.  
  3006. function Drop(What)
  3007.    
  3008.     if What == "up" then
  3009.        
  3010.         local Data = {What = "Function", Function = "DRU"}
  3011.        
  3012.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3013.        
  3014.     elseif What == "forward" then
  3015.        
  3016.         local Data = {What = "Function", Function = "DRF"}
  3017.        
  3018.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3019.        
  3020.     elseif What == "down" then
  3021.        
  3022.         local Data = {What = "Function", Function = "DRD"}
  3023.        
  3024.         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3025.        
  3026.     end
  3027.    
  3028. end
  3029.  
  3030.  
  3031. function SendInfo(ID, What, Data1, Data2)
  3032.    
  3033.     local Data
  3034.    
  3035.     if What == "Function" then
  3036.        
  3037.         if not(Data2) then
  3038.            
  3039.             Data = {What = What, Function = Data1}
  3040.            
  3041.         else
  3042.            
  3043.             Data = {What = What, Function = Data1, Data = Data2}
  3044.            
  3045.         end
  3046.        
  3047.         WModem.Send(ID, Computer.System.Modem.OwnID, Pack(Data))
  3048.        
  3049.     elseif What == "Command" then
  3050.        
  3051.         if not(Data2) then
  3052.            
  3053.             Data = {What = What, Command = Data1}
  3054.  
  3055.         else
  3056.            
  3057.             Data = {What = What, Command = Data1, Data = Data2}
  3058.            
  3059.         end
  3060.        
  3061.         WModem.Send(ID, Computer.System.Modem.OwnID, Pack(Data))
  3062.        
  3063.     end
  3064.    
  3065. end
  3066.  
  3067. function UpDaTe()
  3068.    
  3069.     local done = false
  3070.    
  3071.     for i = 1, #FreeGroupT do
  3072.        
  3073.         local yes = false
  3074.         local Id
  3075.        
  3076.         while not(yes) do
  3077.            
  3078.             local Event, p1, p2, p3, p4, p5 = System.pullEvent("modem_message")
  3079.             Id = p3
  3080.            
  3081.             if not(done) then
  3082.                
  3083.                 done = {}
  3084.                 table.insert(done, p3)
  3085.                 yes = true
  3086.                
  3087.             else
  3088.                
  3089.                 local found = false
  3090.                
  3091.                 for ii = 1, #done do
  3092.                    
  3093.                     if p3 == done[ii] then
  3094.                        
  3095.                         found = true
  3096.                         break
  3097.                        
  3098.                     end
  3099.                    
  3100.                 end
  3101.                
  3102.                 if not(found) then
  3103.                    
  3104.                     table.insert(done, p3)
  3105.                     yes = true
  3106.                    
  3107.                 end
  3108.                
  3109.             end
  3110.            
  3111.         end
  3112.        
  3113.     end
  3114.    
  3115. end
  3116.  
  3117. function onEnter()
  3118.    
  3119.     if (Computer.Connection.Connected) then
  3120.        
  3121.         if nOption == 1 then
  3122.            
  3123.             -- System
  3124.            
  3125.             nSystemOption = 1
  3126.            
  3127.             local Back = false
  3128.            
  3129.             Monitor[0].clear()
  3130.             Monitor[0].setCursorPos(1, 1)
  3131.            
  3132.             while not(Back) do
  3133.                
  3134.                 drawSystemMenu()
  3135.                 drawSystemFrontend()
  3136.                
  3137.                 local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3138.                
  3139.                 if Event == "key" then
  3140.                    
  3141.                     if p1 == keys.up or p1 == keys.numPad8 then
  3142.                        
  3143.                         if nSystemOption > 1 then
  3144.                            
  3145.                             nSystemOption = nSystemOption - 1
  3146.                            
  3147.                         end
  3148.                        
  3149.                     elseif p1 == keys.down or p1 == keys.numPad2 then
  3150.                        
  3151.                         if nSystemOption < MaxSystemOptions then
  3152.                            
  3153.                             nSystemOption = nSystemOption + 1
  3154.                            
  3155.                         end
  3156.                        
  3157.                     elseif p1 == keys.enter or p1 == keys.numPadEnter then
  3158.                        
  3159.                         if nSystemOption == 1 then
  3160.                            
  3161.                             -- DisConnection turtle
  3162.                            
  3163.                             nMonitorTurtleInventoryOption = 0
  3164.                             nMonitorOption = 0
  3165.                             MButtonn = false
  3166.                             ButtonInfo = false
  3167.                             ButtonInventory = false
  3168.                            
  3169.                             Button.clearButtons()
  3170.                             ConnectedID = 0
  3171.                             ConnectedTurtle = {}
  3172.                             Computer.Connection.Connected = false
  3173.                             Back = true
  3174.                            
  3175.                         elseif nSystemOption == 2 then
  3176.                            
  3177.                             -- Reboot
  3178.                            
  3179.                             SaveSettings()
  3180.                             System.reboot()
  3181.                            
  3182.                         elseif nSystemOption == 3 then
  3183.                            
  3184.                             -- Reset
  3185.                            
  3186.                             Monitor[0].clear()
  3187.                             Functions.printCentered(Monitor[0], math.floor(h/2), "Rest Computer? ... Y/N")
  3188.                            
  3189.                             local Event, p1, p2, p3 = System.pullEvent("key")
  3190.                            
  3191.                             if p1 == keys.y then
  3192.                                
  3193.                                 local File = fs.exists("/Progs/.Data/.Settings.set", "r")
  3194.                                
  3195.                                 if File then
  3196.                                    
  3197.                                     Functions.DelFile("/Progs/.Data/.Settings.set")
  3198.                                    
  3199.                                 end
  3200.                                
  3201.                                 System.reboot()
  3202.                                
  3203.                             end
  3204.                            
  3205.                         elseif nSystemOption == 4 then
  3206.                            
  3207.                             Monitor[0].clear()
  3208.                             Functions.printCentered(Monitor[0], math.floor(h/2), "Run Uninstaller? ... Y/N")
  3209.                            
  3210.                             local Event, p1, p2, p3 = System.pullEvent("key")
  3211.                            
  3212.                             if p1 == keys.y then
  3213.                                
  3214.                                 shell.run("/OS/Unintall.lua")
  3215.                                
  3216.                             end
  3217.                            
  3218.                         end
  3219.                        
  3220.                     elseif p1 == keys.b then
  3221.                        
  3222.                         Back = true
  3223.                        
  3224.                     end
  3225.                    
  3226.                 end
  3227.                
  3228.             end
  3229.            
  3230.         elseif nOption == 2 then
  3231.            
  3232.             -- Turtle Info
  3233.            
  3234.             nTurtleInfoOption = 1
  3235.            
  3236.             local Back = false
  3237.            
  3238.             Monitor[0].clear()
  3239.             Monitor[0].setCursorPos(1, 1)
  3240.            
  3241.             while not(Back) do
  3242.                
  3243.                 drawTurtleInfo()
  3244.                
  3245.                 Timer[1] = System.startTimer(5)
  3246.                
  3247.                 local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3248.                
  3249.                 if Event == "key" then
  3250.                    
  3251.                     if p1 == keys.up or p1 == keys.numPad8 then
  3252.                        
  3253.                         System.cancelTimer(Timer[1])
  3254.                        
  3255.                         if nTurtleInfoOption > 1 then
  3256.                            
  3257.                             nTurtleInfoOption = nTurtleInfoOption - 1
  3258.                            
  3259.                         end
  3260.                        
  3261.                     elseif p1 == keys.down or p1 == keys.numPad2 then
  3262.                        
  3263.                         System.cancelTimer(Timer[1])
  3264.                        
  3265.                         if nTurtleInfoOption < MaxTurtleInfoOptions then
  3266.                            
  3267.                             nTurtleInfoOption = nTurtleInfoOption + 1
  3268.                            
  3269.                         end
  3270.                        
  3271.                     elseif p1 == keys.b or p1 == keys.enter or p1 == keys.numPadEnter then
  3272.                        
  3273.                         System.cancelTimer(Timer[1])
  3274.                         Back = true
  3275.                        
  3276.                     end
  3277.                    
  3278.                 elseif Event == "timer" then
  3279.                    
  3280.                     System.cancelTimer(Timer[1])
  3281.                    
  3282.                 end
  3283.                
  3284.             end
  3285.            
  3286.         elseif nOption == 3 then
  3287.            
  3288.             -- Turtle System
  3289.            
  3290.             if Computer.Connection.ConnectedTurtle.Status then
  3291.                
  3292.                 nTurtleSystemOption = 1
  3293.                
  3294.                 local Back = false
  3295.                
  3296.                 Monitor[0].clear()
  3297.                 Monitor[0].setCursorPos(1, 1)
  3298.                
  3299.                 while not(Back) do
  3300.                    
  3301.                     drawTurtleSystemMenu()
  3302.                     drawTurtleSystemFrontend()
  3303.                    
  3304.                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3305.                    
  3306.                     if Event == "key" then
  3307.                        
  3308.                         if p1 == keys.up or p1 == keys.numPad8 then
  3309.                            
  3310.                             if nTurtleSystemOption > 1 then
  3311.                                
  3312.                                 nTurtleSystemOption = nTurtleSystemOption - 1
  3313.                                
  3314.                             end
  3315.                            
  3316.                         elseif p1 == keys.down or p1 == keys.numPad2 then
  3317.                            
  3318.                             if nTurtleSystemOption < MaxTurtleSystemOptions then
  3319.                                
  3320.                                 nTurtleSystemOption = nTurtleSystemOption + 1
  3321.                                
  3322.                             end
  3323.                            
  3324.                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  3325.                            
  3326.                             if nTurtleSystemOption == 1 then
  3327.                                
  3328.                                 local Data = {What = "Command", Command = "/GroupState/"}
  3329.                                
  3330.                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3331.                                
  3332.                                 sleep(1)
  3333.                                
  3334.                                 checkForTurtles()
  3335.                                
  3336.                                 for i = 1, #Turtles do
  3337.                                    
  3338.                                     if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  3339.                                        
  3340.                                         Computer.Connection.ConnectedTurtle = Turtles[i]
  3341.                                        
  3342.                                     end
  3343.                                    
  3344.                                 end
  3345.                                
  3346.                             elseif nTurtleSystemOption == 2 then
  3347.                                
  3348.                                 local Data = {What = "Command", Command = "/ReFuel/"}
  3349.                                
  3350.                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3351.                                
  3352.                                 sleep(1)
  3353.                                
  3354.                                 checkForTurtles()
  3355.                                
  3356.                                 for i = 1, #Turtles do
  3357.                                    
  3358.                                     if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  3359.                                        
  3360.                                         Computer.Connection.ConnectedTurtle = Turtles[i]
  3361.                                        
  3362.                                     end
  3363.                                    
  3364.                                 end
  3365.                                
  3366.                             elseif nTurtleSystemOption == 3 then
  3367.                                
  3368.                                 local Number = ""
  3369.                                
  3370.                                 while type(Number) ~= "number" do
  3371.                                    
  3372.                                     Monitor[0].clear()
  3373.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Number 1/16: ")
  3374.                                    
  3375.                                     Number = tonumber(read())
  3376.                                    
  3377.                                 end
  3378.                                
  3379.                                 local Data = {What = "Command", Command = "/SelectSlot/", Data = Number}
  3380.                                
  3381.                                 WModem.Send(Computer.Connection.ConnectedID, Computer.System.Modem.OwnID, Pack(Data))
  3382.                                
  3383.                             elseif nTurtleSystemOption == 4 then
  3384.                                
  3385.                                 nTurtleEquipOption = 1
  3386.                                
  3387.                                 local TurtleEquipBack = false
  3388.                                
  3389.                                 while not(TurtleEquipBack) do
  3390.                                    
  3391.                                     drawTurtleEquipFrontend()
  3392.                                    
  3393.                                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3394.                                    
  3395.                                     if Event == "key" then
  3396.                                        
  3397.                                         if p1 == keys.up or p1 == keys.numPad8 then
  3398.                                            
  3399.                                             if nTurtleEquipOption > 1 then
  3400.                                                
  3401.                                                 nTurtleEquipOption = nTurtleEquipOption - 1
  3402.                                                
  3403.                                             end
  3404.                                            
  3405.                                         elseif p1 == keys.down or p1 == keys.numPad2 then
  3406.                                            
  3407.                                             if nTurtleEquipOption < MaxTurtleEquipOptions then
  3408.                                                
  3409.                                                 nTurtleEquipOption = nTurtleEquipOption + 1
  3410.                                                
  3411.                                             end
  3412.                                            
  3413.                                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  3414.                                            
  3415.                                             if nTurtleEquipOption == 1 then
  3416.                                                
  3417.                                                 local Data = {What = "Command", Command = "/EqUip/", Data = "left"}
  3418.                                                
  3419.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3420.                                                
  3421.                                             elseif nTurtleEquipOption == 2 then
  3422.                                                
  3423.                                                 local Data = {What = "Command", Command = "/EqUip/", Data = "right"}
  3424.                                                
  3425.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3426.                                                
  3427.                                             end
  3428.                                            
  3429.                                             TurtleEquipBack = true
  3430.                                            
  3431.                                         elseif p1 == keys.b then
  3432.                                            
  3433.                                             TurtleEquipBack = true
  3434.                                            
  3435.                                         end
  3436.                                        
  3437.                                     end
  3438.                                    
  3439.                                 end
  3440.                                
  3441.                             elseif nTurtleSystemOption == 5 then
  3442.                                
  3443.                                 local Number = ""
  3444.                                
  3445.                                 while type(Number) ~= "number" do
  3446.                                    
  3447.                                     Monitor[0].clear()
  3448.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Number 1/16: ")
  3449.                                    
  3450.                                     Number = tonumber(read())
  3451.                                    
  3452.                                 end
  3453.                                
  3454.                                 local Data = {What = "Command", Command = "/TransferTo/", Data = Number}
  3455.                                
  3456.                                 WModem.Send(Computer.Connection.ConnectedID, Computer.System.Modem.OwnID, Pack(Data))
  3457.                                
  3458.                             elseif nTurtleSystemOption == 6 then
  3459.                                
  3460.                                 local Data = {What = "Command", Command = "/CrAft/"}
  3461.                                
  3462.                                 WModem.Send(Computer.Connection.ConnectedID, Computer.System.Modem.OwnID, Pack(Data))
  3463.                                
  3464.                             elseif nTurtleSystemOption == 7 then
  3465.                                
  3466.                                 nTurtleDetectOption = 1
  3467.                                
  3468.                                 local TurtleDetectBack = false
  3469.                                
  3470.                                 while not(TurtleDetectBack) do
  3471.                                    
  3472.                                     drawTurtleDetectFrontend()
  3473.                                    
  3474.                                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3475.                                    
  3476.                                     if Event == "key" then
  3477.                                        
  3478.                                         if p1 == keys.up or p1 == keys.numPad8 then
  3479.                                            
  3480.                                             if nTurtleDetectOption > 1 then
  3481.                                                
  3482.                                                 nTurtleDetectOption = nTurtleDetectOption - 1
  3483.                                                
  3484.                                             end
  3485.                                            
  3486.                                         elseif p1 == keys.down or p1 == keys.numPad2 then
  3487.                                            
  3488.                                             if nTurtleDetectOption < MaxTurtleDetectOptions then
  3489.                                                
  3490.                                                 nTurtleDetectOption = nTurtleDetectOption + 1
  3491.                                                
  3492.                                             end
  3493.                                            
  3494.                                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  3495.                                            
  3496.                                             if nTurtleDetectOption == 1 then
  3497.                                                
  3498.                                                 local Data = {What = "Command", Command = "/DeTect/", Data = "forward"}
  3499.                                                
  3500.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3501.                                                
  3502.                                             elseif nTurtleDetectOption == 2 then
  3503.                                                
  3504.                                                 local Data = {What = "Command", Command = "/DeTect/", Data = "up"}
  3505.                                                
  3506.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3507.                                                
  3508.                                             elseif nTurtleDetectOption == 3 then
  3509.                                                
  3510.                                                 local Data = {What = "Command", Command = "/DeTect/", Data = "down"}
  3511.                                                
  3512.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3513.                                                
  3514.                                             end
  3515.                                            
  3516.                                             sleep(1)
  3517.                                            
  3518.                                             checkForTurtles()
  3519.                                            
  3520.                                             for i = 1, #Turtles do
  3521.                                                
  3522.                                                 if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  3523.                                                    
  3524.                                                     Computer.Connection.ConnectedTurtle = Turtles[i]
  3525.                                                    
  3526.                                                 end
  3527.                                                
  3528.                                             end
  3529.                                            
  3530.                                             TurtleDetectBack = true
  3531.                                            
  3532.                                         elseif p1 == keys.b then
  3533.                                            
  3534.                                             TurtleDetectBack = true
  3535.                                            
  3536.                                         end
  3537.                                        
  3538.                                     end
  3539.                                    
  3540.                                 end
  3541.                                
  3542.                             elseif nTurtleSystemOption == 8 then
  3543.                                
  3544.                                 nTurtleInspectOption = 1
  3545.                                
  3546.                                 local TurtleInspectBack = false
  3547.                                
  3548.                                 while not(TurtleInspectBack) do
  3549.                                    
  3550.                                     drawTurtleInspectFrontend()
  3551.                                    
  3552.                                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3553.                                    
  3554.                                     if Event == "key" then
  3555.                                        
  3556.                                         if p1 == keys.up or p1 == keys.numPad8 then
  3557.                                            
  3558.                                             if nTurtleInspectOption > 1 then
  3559.                                                
  3560.                                                 nTurtleInspectOption = nTurtleInspectOption - 1
  3561.                                                
  3562.                                             end
  3563.                                            
  3564.                                         elseif p1 == keys.down or p1 == keys.numPad2 then
  3565.                                            
  3566.                                             if nTurtleInspectOption < MaxTurtleInspectOptions then
  3567.                                                
  3568.                                                 nTurtleInspectOption = nTurtleInspectOption + 1
  3569.                                                
  3570.                                             end
  3571.                                            
  3572.                                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  3573.                                            
  3574.                                             local Side
  3575.                                            
  3576.                                             if nTurtleInspectOption == 1 then
  3577.                                                
  3578.                                                 local Data = {What = "Command", Command = "/InSpect/", Data = "forward"}
  3579.                                                
  3580.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3581.                                                
  3582.                                                 Side = "forward"
  3583.                                                
  3584.                                             elseif nTurtleInspectOption == 2 then
  3585.                                                
  3586.                                                 local Data = {What = "Command", Command = "/InSpect/", Data = "up"}
  3587.                                                
  3588.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3589.                                                
  3590.                                                 Side = "up"
  3591.                                                
  3592.                                             elseif nTurtleInspectOption == 3 then
  3593.                                                
  3594.                                                 local Data = {What = "Command", Command = "/InSpect/", Data = "down"}
  3595.                                                
  3596.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3597.                                                
  3598.                                                 Side = "down"
  3599.                                                
  3600.                                             end
  3601.                                            
  3602.                                             sleep(1)
  3603.                                            
  3604.                                             checkForTurtles()
  3605.                                            
  3606.                                             for i = 1, #Turtles do
  3607.                                                
  3608.                                                 if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  3609.                                                    
  3610.                                                     Computer.Connection.ConnectedTurtle = Turtles[i]
  3611.                                                    
  3612.                                                 end
  3613.                                                
  3614.                                             end
  3615.                                            
  3616.                                             local TurtleInspectInfoBack = false
  3617.                                            
  3618.                                             local Table = {}
  3619.                                            
  3620.                                             if Side == "forward" then
  3621.                                                
  3622.                                                 Table = Computer.Connection.ConnectedTurtle.Inspect.Forward
  3623.                                                
  3624.                                             elseif Side == "up" then
  3625.                                                
  3626.                                                 Table = Computer.Connection.ConnectedTurtle.Inspect.Up
  3627.                                                
  3628.                                             elseif Side == "down" then
  3629.                                                
  3630.                                                 Table = Computer.Connevtion.ConnectedTurtle.Inspect.Down
  3631.                                                
  3632.                                             end
  3633.                                            
  3634.                                             while not(TurtleInspectInfoBack) do
  3635.                                                
  3636.                                                 drawTurtleInspectInfoFrontend(Table)
  3637.                                                
  3638.                                                 local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3639.                                                
  3640.                                                 if Event == "key" then
  3641.                                                    
  3642.                                                     if p1 == keys.b or p1 == keys.enter or p1 == keys.numPadEnter then
  3643.                                                        
  3644.                                                         TurtleInspectInfoBack = true
  3645.                                                        
  3646.                                                     end
  3647.                                                    
  3648.                                                 end
  3649.                                                
  3650.                                             end
  3651.                                            
  3652.                                         elseif p1 == keys.b then
  3653.                                            
  3654.                                             TurtleInspectBack = true
  3655.                                            
  3656.                                         end
  3657.                                        
  3658.                                     end
  3659.                                    
  3660.                                 end
  3661.                                
  3662.                             elseif nTurtleSystemOption == 9 then
  3663.                                
  3664.                                 nTurtleCompareOption = 1
  3665.                                
  3666.                                 local TurtleCompareBack = false
  3667.                                
  3668.                                 while not(TurtleCompareBack) do
  3669.                                    
  3670.                                     drawTurtleCompareFrontend()
  3671.                                    
  3672.                                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3673.                                    
  3674.                                     if Event == "key" then
  3675.                                        
  3676.                                         if p1 == keys.up or p1 == keys.numPad8 then
  3677.                                            
  3678.                                             if nTurtleCompareOption > 1 then
  3679.                                                
  3680.                                                 nTurtleCompareOption = nTurtleCompareOption - 1
  3681.                                                
  3682.                                             end
  3683.                                            
  3684.                                         elseif p1 == keys.down or p1 == keys.numPad2 then
  3685.                                            
  3686.                                             if nTurtleCompareOption < MaxTurtleCompareOptions then
  3687.                                                
  3688.                                                 nTurtleCompareOption = nTurtleCompareOption + 1
  3689.                                                
  3690.                                             end
  3691.                                            
  3692.                                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  3693.                                            
  3694.                                             if nTurtleCompareOption == 1 then
  3695.                                                
  3696.                                                 local Data = {What = "Command", Command = "/ComPare/", Data = "forward"}
  3697.                                                
  3698.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3699.                                                
  3700.                                             elseif nTurtleCompareOption == 2 then
  3701.                                                
  3702.                                                 local Data = {What = "Command", Command = "/ComPare/", Data = "up"}
  3703.                                                
  3704.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3705.                                                
  3706.                                             elseif nTurtleCompareOption == 3 then
  3707.                                                
  3708.                                                 local Data = {What = "Command", Command = "/ComPare/", Data = "down"}
  3709.                                                
  3710.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3711.                                                
  3712.                                             end
  3713.                                            
  3714.                                             sleep(1)
  3715.                                            
  3716.                                             checkForTurtles()
  3717.                                            
  3718.                                             for i = 1, #Turtles do
  3719.                                                
  3720.                                                 if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  3721.                                                    
  3722.                                                     Computer.Connection.ConnectedTurtle = Turtles[i]
  3723.                                                    
  3724.                                                 end
  3725.                                                
  3726.                                             end
  3727.                                            
  3728.                                             TurtleCompareBack = true
  3729.                                            
  3730.                                         elseif p1 == keys.b then
  3731.                                            
  3732.                                             TurtleCompareBack = true
  3733.                                            
  3734.                                         end
  3735.                                        
  3736.                                     end
  3737.                                    
  3738.                                 end
  3739.                                
  3740.                             elseif nTurtleSystemOption == 10 then
  3741.                                
  3742.                                 if Computer.Connection.ConnectedTurtleId ~= Computer.System.Modem.SharedID then
  3743.                                    
  3744.                                     local Data = {What = "Command", Command = "/PrintLog/"}
  3745.                                    
  3746.                                     WModem.Send(Computer.Connection.ConnectedID, Computer.System.Modem.OwnID, Pack(Data))
  3747.                                    
  3748.                                 end
  3749.                                
  3750.                             elseif nTurtleSystemOption == 11 then
  3751.                                
  3752.                                 local Data = {What = "Command", Command = "/ReBoot/"}
  3753.                                
  3754.                                 WModem.Send(Computer.Connection.ConnectedID, Computer.System.Modem.OwnID, Pack(Data))
  3755.                                
  3756.                             elseif nTurtleSystemOption == 12 then
  3757.                                
  3758.                                 local Data = {What = "Command", Command = "/ShutDown/"}
  3759.                                
  3760.                                 WModem.Send(Computer.Connection.ConnectedID, Computer.System.Modem.OwnID, Pack(Data))
  3761.                                
  3762.                                 nOption = 1
  3763.                                 ConnectedID = 0
  3764.                                 ConnectedTurtle = {}
  3765.                                 Computer.Connection.Connected = false
  3766.                                 Back = true
  3767.                                
  3768.                             elseif nTurtleSystemOption == 13 then
  3769.                                
  3770.                                 Monitor[0].clear()
  3771.                                 Functions.printCentered(Monitor[0], math.floor(h/2), "Reset Turtle? ... Y/N")
  3772.                                
  3773.                                 local Event, p1, p2, p3 = System.pullEvent("key")
  3774.                                
  3775.                                 if p1 == keys.y then
  3776.                                    
  3777.                                     local Data = {What = "Command", Command = "/ReSet/"}
  3778.                                    
  3779.                                     WModem.Send(Computer.Connection.ConnectedID, Computer.System.Modem.OwnID, Pack(Data))
  3780.                                    
  3781.                                     nOption = 1
  3782.                                     ConnectedID = 0
  3783.                                     ConnectedTurtle = {}
  3784.                                     Computer.Connection.Connected = false
  3785.                                     Back = true
  3786.                                    
  3787.                                 end
  3788.                                
  3789.                             end
  3790.                            
  3791.                         elseif p1 == keys.b then
  3792.                            
  3793.                             Back = true
  3794.                            
  3795.                         end
  3796.                        
  3797.                     end
  3798.                    
  3799.                 end
  3800.                
  3801.             end
  3802.            
  3803.         elseif nOption == 4 then
  3804.            
  3805.             -- Turtle Movements
  3806.            
  3807.             if Computer.Connection.ConnectedTurtle.Status then
  3808.                
  3809.                 nTurtleMovementsOption = 1
  3810.                
  3811.                 local Back = false
  3812.                
  3813.                 Monitor[0].clear()
  3814.                 Monitor[0].setCursorPos(1, 1)
  3815.                
  3816.                 while not(Back) do
  3817.                    
  3818.                     drawTurtleMovementsMenu()
  3819.                     drawTurtleMovementsFrontend()
  3820.                    
  3821.                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3822.                    
  3823.                     if Event == "key" then
  3824.                        
  3825.                         if p1 == keys.up or p1 == keys.numPad8 then
  3826.                            
  3827.                             if nTurtleMovementsOption > 1 then
  3828.                                
  3829.                                 nTurtleMovementsOption = nTurtleMovementsOption - 1
  3830.                                
  3831.                             end
  3832.                            
  3833.                         elseif p1 == keys.down or p1 == keys.numPad2 then
  3834.                            
  3835.                             if nTurtleMovementsOption < MaxTurtleMovementsOptions then
  3836.                                
  3837.                                 nTurtleMovementsOption = nTurtleMovementsOption + 1
  3838.                                
  3839.                             end
  3840.                            
  3841.                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  3842.                            
  3843.                             if nTurtleMovementsOption == 1 then
  3844.                                
  3845.                                 nTurtleAttackOption = 1
  3846.                                
  3847.                                 local AttackBack = false
  3848.                                
  3849.                                 while not(AttackBack) do
  3850.                                    
  3851.                                     drawTurtleAttackFrontend()
  3852.                                    
  3853.                                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3854.                                    
  3855.                                     if Event == "key" then
  3856.                                        
  3857.                                         if p1 == keys.up or p1 == keys.numPad8 then
  3858.                                            
  3859.                                             if nTurtleAttackOption > 1 then
  3860.                                                
  3861.                                                 nTurtleAttackOption = nTurtleAttackOption - 1
  3862.                                                
  3863.                                             end
  3864.                                            
  3865.                                         elseif p1 == keys.down or p1 == keys.numPad2 then
  3866.                                            
  3867.                                             if nTurtleAttackOption < MaxTurtleAttackOptions then
  3868.                                                
  3869.                                                 nTurtleAttackOption = nTurtleAttackOption + 1
  3870.                                                
  3871.                                             end
  3872.                                            
  3873.                                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  3874.                                            
  3875.                                             if nTurtleAttackOption == 1 then
  3876.                                                
  3877.                                                 local Data = {What = "Command", Command = "/AtTack/", Data = "forward"}
  3878.                                                
  3879.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3880.                                                
  3881.                                             elseif nTurtleAttackOption == 2 then
  3882.                                                
  3883.                                                 local Data = {What = "Command", Command = "/AtTack/", Data = "up"}
  3884.                                                
  3885.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3886.                                                
  3887.                                             elseif nTurtleAttackOption == 3 then
  3888.                                                
  3889.                                                 local Data = {What = "Command", Command = "/AtTack/", Data = "down"}
  3890.                                                
  3891.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3892.                                                
  3893.                                             end
  3894.                                            
  3895.                                             AttackBack = true
  3896.                                            
  3897.                                         elseif p1 == keys.b then
  3898.                                            
  3899.                                             AttackBack = true
  3900.                                            
  3901.                                         end
  3902.                                        
  3903.                                     end
  3904.                                    
  3905.                                 end
  3906.                                
  3907.                             elseif nTurtleMovementsOption == 2 then
  3908.                                
  3909.                                 nTurtleDigOption = 1
  3910.                                
  3911.                                 local DigBack = false
  3912.                                
  3913.                                 while not(DigBack) do
  3914.                                    
  3915.                                     drawTurtleDigFrontend()
  3916.                                    
  3917.                                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3918.                                    
  3919.                                     if Event == "key" then
  3920.                                        
  3921.                                         if p1 == keys.up or p1 == keys.numPad8 then
  3922.                                            
  3923.                                             if nTurtleDigOption > 1 then
  3924.                                                
  3925.                                                 nTurtleDigOption = nTurtleDigOption - 1
  3926.                                                
  3927.                                             end
  3928.                                            
  3929.                                         elseif p1 == keys.down or p1 == keys.numPad2 then
  3930.                                            
  3931.                                             if nTurtleDigOption < MaxTurtleDigOptions then
  3932.                                                
  3933.                                                 nTurtleDigOption = nTurtleDigOption + 1
  3934.                                                
  3935.                                             end
  3936.                                            
  3937.                                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  3938.                                            
  3939.                                             if nTurtleDigOption == 1 then
  3940.                                                
  3941.                                                 local Data = {What = "Command", Command = "/DiG/", Data = "forward"}
  3942.                                                
  3943.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3944.                                                
  3945.                                             elseif nTurtleDigOption == 2 then
  3946.                                                
  3947.                                                 local Data = {What = "Command", Command = "/DiG/", Data = "up"}
  3948.                                                
  3949.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3950.                                                
  3951.                                             elseif nTurtleDigOption == 3 then
  3952.                                                
  3953.                                                 local Data = {What = "Command", Command = "/DiG/", Data = "down"}
  3954.                                                
  3955.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  3956.                                                
  3957.                                             end
  3958.                                            
  3959.                                             DigBack = true
  3960.                                            
  3961.                                         elseif p1 == keys.b then
  3962.                                            
  3963.                                             DigBack = true
  3964.                                            
  3965.                                         end
  3966.                                        
  3967.                                     end
  3968.                                    
  3969.                                 end
  3970.                                
  3971.                                 sleep(1)
  3972.                                
  3973.                                 checkForTurtles()
  3974.                                
  3975.                                 for i = 1, #Turtles do
  3976.                                    
  3977.                                     if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  3978.                                        
  3979.                                         Computer.Connection.ConnectedTurtle = Turtles[i]
  3980.                                        
  3981.                                     end
  3982.                                    
  3983.                                 end
  3984.                                
  3985.                             elseif nTurtleMovementsOption == 3 then
  3986.                                
  3987.                                 nTurtleSuckOption = 1
  3988.                                
  3989.                                 local SuckBack = false
  3990.                                
  3991.                                 while not(SuckBack) do
  3992.                                    
  3993.                                     drawTurtleSuckFrontend()
  3994.                                    
  3995.                                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  3996.                                    
  3997.                                     if Event == "key" then
  3998.                                        
  3999.                                         if p1 == keys.up or p1 == keys.numPad8 then
  4000.                                            
  4001.                                             if nTurtleSuckOption > 1 then
  4002.                                                
  4003.                                                 nTurtleSuckOption = nTurtleSuckOption - 1
  4004.                                                
  4005.                                             end
  4006.                                            
  4007.                                         elseif p1 == keys.down or p1 == keys.numPad2 then
  4008.                                            
  4009.                                             if nTurtleSuckOption < MaxTurtleSuckOptions then
  4010.                                                
  4011.                                                 nTurtleSuckOption = nTurtleSuckOption + 1
  4012.                                                
  4013.                                             end
  4014.                                            
  4015.                                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  4016.                                            
  4017.                                             if nTurtleSuckOption == 1 then
  4018.                                                
  4019.                                                 local Data = {What = "Command", Command = "/SuCk/", Data = "forward"}
  4020.                                                
  4021.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4022.                                                
  4023.                                             elseif nTurtleSuckOption == 2 then
  4024.                                                
  4025.                                                 local Data = {What = "Command", Command = "/SuCk/", Data = "up"}
  4026.                                                
  4027.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4028.                                                
  4029.                                             elseif nTurtleSuckOption == 3 then
  4030.                                                
  4031.                                                 local Data = {What = "Command", Command = "/SuCk/", Data = "down"}
  4032.                                                
  4033.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4034.                                                
  4035.                                             end
  4036.                                            
  4037.                                             SuckBack = true
  4038.                                            
  4039.                                         elseif p1 == keys.b then
  4040.                                            
  4041.                                             SuckBack = true
  4042.                                            
  4043.                                         end
  4044.                                        
  4045.                                     end
  4046.                                    
  4047.                                 end
  4048.                                
  4049.                             elseif nTurtleMovementsOption == 4 then
  4050.                                
  4051.                                 nTurtleDropOption = 1
  4052.                                
  4053.                                 local DropBack = false
  4054.                                
  4055.                                 while not(DropBack) do
  4056.                                    
  4057.                                     drawTurtleDropFrontend()
  4058.                                    
  4059.                                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  4060.                                    
  4061.                                     if Event == "key" then
  4062.                                        
  4063.                                         if p1 == keys.up or p1 == keys.numPad8 then
  4064.                                            
  4065.                                             if nTurtleDropOption > 1 then
  4066.                                                
  4067.                                                 nTurtleDropOption = nTurtleDropOption - 1
  4068.                                                
  4069.                                             end
  4070.                                            
  4071.                                         elseif p1 == keys.down or p1 == keys.numPad2 then
  4072.                                            
  4073.                                             if nTurtleDropOption < MaxTurtleDropOptions then
  4074.                                                
  4075.                                                 nTurtleDropOption = nTurtleDropOption + 1
  4076.                                                
  4077.                                             end
  4078.                                            
  4079.                                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  4080.                                            
  4081.                                             if nTurtleDropOption == 1 then
  4082.                                                
  4083.                                                 local Data = {What = "Command", Command = "/DrOp/", Data = "forward"}
  4084.                                                
  4085.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4086.                                                
  4087.                                             elseif nTurtleDropOption == 2 then
  4088.                                                
  4089.                                                 local Data = {What = "Command", Command = "/DrOp/", Data = "up"}
  4090.                                                
  4091.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4092.                                                
  4093.                                             elseif nTurtleDropOption == 3 then
  4094.                                                
  4095.                                                 local Data = {What = "Command", Command = "/DrOp/", Data = "down"}
  4096.                                                
  4097.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4098.                                                
  4099.                                             end
  4100.                                            
  4101.                                             DropBack = true
  4102.                                            
  4103.                                         elseif p1 == keys.b then
  4104.                                            
  4105.                                             DropBack = true
  4106.                                            
  4107.                                         end
  4108.                                        
  4109.                                     end
  4110.                                    
  4111.                                 end
  4112.  
  4113.                             elseif nTurtleMovementsOption == 5 then
  4114.                                
  4115.                                 nTurtlePlaceOption = 1
  4116.                                
  4117.                                 local PlaceBack = false
  4118.                                
  4119.                                 while not(PlaceBack) do
  4120.                                    
  4121.                                     drawTurtlePlaceFrontend()
  4122.                                    
  4123.                                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  4124.                                    
  4125.                                     if Event == "key" then
  4126.                                        
  4127.                                         if p1 == keys.up or p1 == keys.numPad8 then
  4128.                                            
  4129.                                             if nTurtlePlaceOption > 1 then
  4130.                                                
  4131.                                                 nTurtlePlaceOption = nTurtlePlaceOption - 1
  4132.                                                
  4133.                                             end
  4134.                                            
  4135.                                         elseif p1 == keys.down or p1 == keys.numPad2 then
  4136.                                            
  4137.                                             if nTurtlePlaceOption < MaxTurtlePlaceOptions then
  4138.                                                
  4139.                                                 nTurtlePlaceOption = nTurtlePlaceOption + 1
  4140.                                                
  4141.                                             end
  4142.                                            
  4143.                                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  4144.                                            
  4145.                                             if nTurtlePlaceOption == 1 then
  4146.                                                
  4147.                                                 local Data = {What = "Command", Command = "/PlAce/", Data = "forward"}
  4148.                                                
  4149.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4150.                                                
  4151.                                             elseif nTurtlePlaceOption == 2 then
  4152.                                                
  4153.                                                 local Data = {What = "Command", Command = "/PlAce/", Data = "up"}
  4154.                                                
  4155.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4156.                                                
  4157.                                             elseif nTurtlePlaceOption == 3 then
  4158.                                                
  4159.                                                 local Data = {What = "Command", Command = "/PlAce/", Data = "down"}
  4160.                                                
  4161.                                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4162.                                                
  4163.                                             end
  4164.                                            
  4165.                                             PlaceBack = true
  4166.                                            
  4167.                                         elseif p1 == keys.b then
  4168.                                            
  4169.                                             PlaceBack = true
  4170.                                            
  4171.                                         end
  4172.                                        
  4173.                                     end
  4174.                                    
  4175.                                 end
  4176.                                
  4177.                                 sleep(1)
  4178.                                
  4179.                                 checkForTurtles()
  4180.                                
  4181.                                 for i = 1, #Turtles do
  4182.                                    
  4183.                                     if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  4184.                                        
  4185.                                         Computer.Connection.ConnectedTurtle = Turtles[i]
  4186.                                        
  4187.                                     end
  4188.                                    
  4189.                                 end
  4190.                                
  4191.                             elseif nTurtleMovementsOption == 6 then
  4192.                                
  4193.                                 Monitor[0].clear()
  4194.                                 Functions.printCentered(Monitor[0], math.floor(h/2), "X Cor: ")
  4195.                                 local X = tonumber(read())
  4196.                                 Functions.printCentered(Monitor[0], math.floor(h/2), "Y Cor: ")
  4197.                                 local Y = tonumber(read())
  4198.                                 Functions.printCentered(Monitor[0], math.floor(h/2), "Z Cor: ")
  4199.                                 local Z = tonumber(read())
  4200.                                
  4201.                                 local Cor = {X = X, Y = Y, Z = Z}
  4202.                                 local Data = {What = "Command", Command = "/GoTo/", Data = Cor}
  4203.                                
  4204.                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4205.                                
  4206.                             elseif nTurtleMovementsOption == 7 then
  4207.                                
  4208.                                 local Data = {What = "Command", Command = "/GoHome/"}
  4209.                                
  4210.                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4211.                                
  4212.                                 sleep(1)
  4213.                                
  4214.                                 checkForTurtles()
  4215.                                
  4216.                                 for i = 1, #Turtles do
  4217.                                    
  4218.                                     if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  4219.                                        
  4220.                                         Computer.Connection.ConnectedTurtle = Turtles[i]
  4221.                                        
  4222.                                     end
  4223.                                    
  4224.                                 end
  4225.                                
  4226.                             elseif nTurtleMovementsOption == 8 then
  4227.                                
  4228.                                 Monitor[0].clear()
  4229.                                 Functions.printCentered(Monitor[0], math.floor(h/2), "1 = North, 2 = East, 3 = South, 4 = West: ")
  4230.                                 local R = tonumber(read())
  4231.                                
  4232.                                 local Data = {What = "Command", Command = "/TurnDirection/", Data = R}
  4233.                                
  4234.                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4235.                                
  4236.                                 sleep(1)
  4237.                                
  4238.                                 checkForTurtles()
  4239.                                
  4240.                                 for i = 1, #Turtles do
  4241.                                    
  4242.                                     if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  4243.                                        
  4244.                                         Computer.Connection.ConnectedTurtle = Turtles[i]
  4245.                                        
  4246.                                     end
  4247.                                    
  4248.                                 end
  4249.                                
  4250.                             elseif nTurtleMovementsOption == 9 then
  4251.                                
  4252.                                 local Data = {What = "Command", Command = "/EmptyInventory/"}
  4253.                                
  4254.                                 WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4255.                                
  4256.                             end
  4257.                            
  4258.                         elseif p1 == keys.w and p2 then
  4259.                            
  4260.                             Monitor[0].clear()
  4261.                             Functions.printCentered(Monitor[0], math.floor(h/2), "How manny blocks: ")
  4262.                             local Number = tonumber(read())
  4263.                            
  4264.                             for i = 1, Number - 1 do
  4265.                                
  4266.                                 Move("forward")
  4267.                                
  4268.                                 sleep(3)
  4269.                                
  4270.                             end
  4271.                            
  4272.                         elseif p1 == keys.w then
  4273.                            
  4274.                             Move("forward")
  4275.                            
  4276.                         elseif p1 == keys.s and p2 then
  4277.                            
  4278.                             Monitor[0].clear()
  4279.                             Functions.printCentered(Monitor[0], math.floor(h/2), "How manny blocks: ")
  4280.                             local Number = tonumber(read())
  4281.                            
  4282.                             for i = 1, Number - 1 do
  4283.                                
  4284.                                 Move("back")
  4285.                                
  4286.                                 sleep(3)
  4287.                                
  4288.                             end
  4289.                            
  4290.                         elseif p1 == keys.s then
  4291.                            
  4292.                             Move("back")
  4293.                            
  4294.                         elseif p1 == keys.a then
  4295.                            
  4296.                             Move("left")
  4297.                            
  4298.                         elseif p1 == keys.d then
  4299.                            
  4300.                             Move("right")
  4301.                            
  4302.                         elseif p1 == keys.r and p2 then
  4303.                            
  4304.                             Monitor[0].clear()
  4305.                             Functions.printCentered(Monitor[0], math.floor(h/2), "How manny blocks: ")
  4306.                             local Number = tonumber(read())
  4307.                            
  4308.                             for i = 1, Number - 1 do
  4309.                                
  4310.                                 Move("up")
  4311.                                
  4312.                                 sleep(3)
  4313.                                
  4314.                             end
  4315.                            
  4316.                         elseif p1 == keys.r then
  4317.                            
  4318.                             Move("up")
  4319.                            
  4320.                         elseif p1 == keys.f and p2 then
  4321.                            
  4322.                             Monitor[0].clear()
  4323.                             Functions.printCentered(Monitor[0], math.floor(h/2), "How manny blocks: ")
  4324.                             local Number = tonumber(read())
  4325.                            
  4326.                             for i = 1, Number - 1 do
  4327.                                
  4328.                                 Move("down")
  4329.                                
  4330.                                 sleep(3)
  4331.                                
  4332.                             end
  4333.                            
  4334.                         elseif p1 == keys.f then
  4335.                            
  4336.                             Move("down")
  4337.                            
  4338.                         elseif p1 == keys.b then
  4339.                            
  4340.                             Back = true
  4341.                            
  4342.                         end
  4343.                        
  4344.                     elseif Event == "mouse_click" then
  4345.                        
  4346.                         local Butt, MX, MY = p1, p2, p3
  4347.                        
  4348.                         Button.buttonPressed(MX,MY)
  4349.                        
  4350.                     end
  4351.                    
  4352.                 end
  4353.                
  4354.             end
  4355.            
  4356.         elseif nOption == 5 then
  4357.            
  4358.             -- Turtle Program's
  4359.            
  4360.             if Computer.Connection.ConnectedTurtle.Status then
  4361.                
  4362.                 nTurtleProgramsOption = 1
  4363.                
  4364.                 local Back = false
  4365.                
  4366.                 Monitor[0].clear()
  4367.                 Monitor[0].setCursorPos(1, 1)
  4368.                
  4369.                 while not(Back) do
  4370.                    
  4371.                     drawTurtleProgramsMenu()
  4372.                     drawTurtleProgramsFrontend()
  4373.                    
  4374.                     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  4375.                    
  4376.                     if Event == "key" then
  4377.                        
  4378.                         if p1 == keys.up or p1 == keys.numPad8 then
  4379.                            
  4380.                             if nTurtleProgramsOption > 1 then
  4381.                                
  4382.                                 nTurtleProgramsOption = nTurtleProgramsOption - 1
  4383.                                
  4384.                             end
  4385.                            
  4386.                         elseif p1 == keys.down or p1 == keys.numPad2 then
  4387.                            
  4388.                             if nTurtleProgramsOption < MaxTurtleProgramsOptions then
  4389.                                
  4390.                                 nTurtleProgramsOption = nTurtleProgramsOption + 1
  4391.                                
  4392.                             end
  4393.                            
  4394.                         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  4395.                            
  4396.                             if not(Computer.System.Nether) then
  4397.                                
  4398.                                 if nTurtleProgramsOption == 1 then
  4399.                                    
  4400.                                     Monitor[0].clear()
  4401.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry X: ")
  4402.                                     local X = tonumber(read())
  4403.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry Y: ")
  4404.                                     local Y = tonumber(read())
  4405.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry Z: ")
  4406.                                     local Z = tonumber(read())
  4407.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Blocks (front): ")
  4408.                                     local Blocks = tonumber(read())
  4409.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Lines (side): ")
  4410.                                     local Lines = tonumber(read())
  4411.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Layers (down): ")
  4412.                                     local Layers = tonumber(read())
  4413.                                    
  4414.                                     if Computer.Connection.ConnectedTurtle.Id == Computer.System.Modem.SharedID then
  4415.                                        
  4416.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "On x (E/W) or on z (N/S) ax: ")
  4417.                                         local Ax = tonumber(read())
  4418.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "plus (S/E) or min (N/W): ")
  4419.                                         local Way = tonumber(read())
  4420.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "How many between: ")
  4421.                                         local Between = tonumber(read())
  4422.                                        
  4423.                                         Monitor[0].clear()
  4424.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "One Moment Please...")
  4425.                                        
  4426.                                         if Ax == string.lower("x") and Way == string.lower("plus") then
  4427.                                            
  4428.                                             for i = 1, #Turtles do
  4429.                                                
  4430.                                                 if Turtles[i].GroupState == true then
  4431.                                                    
  4432.                                                     sleep(5)
  4433.                                                    
  4434.                                                     local Data = {What = "Command", Command = "QuArry", Data = {X = TargetX, Y = TargetY, Z = TargetZ, Blocks = Blocks, Lines = Lines, Layers = Layers}}
  4435.                                                    
  4436.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4437.                                                    
  4438.                                                     if Between ~= 0 and Between ~= nil then
  4439.                                                        
  4440.                                                         X = X + Lines + Between
  4441.                                                        
  4442.                                                     else
  4443.                                                        
  4444.                                                         X = X + Lines
  4445.                                                        
  4446.                                                     end
  4447.                                                    
  4448.                                                 end
  4449.                                                
  4450.                                             end
  4451.                                            
  4452.                                         elseif Ax == string.lower("x") and Way == string.lower("min") then
  4453.                                            
  4454.                                             for i = 1, #Turtles do
  4455.                                                
  4456.                                                 if Turtles[i].GroupState == true then
  4457.                                                    
  4458.                                                     sleep(5)
  4459.                                                    
  4460.                                                     local Data = {What = "Command", Command = "QuArry", Data = {X = TargetX, Y = TargetY, Z = TargetZ, Blocks = Blocks, Lines = Lines, Layers = Layers}}
  4461.                                                    
  4462.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4463.                                                    
  4464.                                                     if Between ~= 0 and Between ~= nil then
  4465.                                                        
  4466.                                                         X = X - Lines - Between
  4467.                                                        
  4468.                                                     else
  4469.                                                        
  4470.                                                         X = X - Lines
  4471.                                                        
  4472.                                                     end
  4473.                                                    
  4474.                                                 end
  4475.                                                
  4476.                                             end
  4477.                                            
  4478.                                         elseif Ax == string.lower("z") and Way == string.lower("plus") then
  4479.                                            
  4480.                                             for i = 1, #Turtles do
  4481.                                                
  4482.                                                 if Turtles[i].GroupState == true then
  4483.                                                    
  4484.                                                     sleep(5)
  4485.                                                    
  4486.                                                     local Data = {What = "Command", Command = "QuArry", Data = {X = TargetX, Y = TargetY, Z = TargetZ, Blocks = Blocks, Lines = Lines, Layers = Layers}}
  4487.                                                    
  4488.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4489.                                                    
  4490.                                                     if Between ~= 0 and Between ~= nil then
  4491.                                                        
  4492.                                                         Z = Z + (Blocks + 1) + Between
  4493.                                                        
  4494.                                                     else   
  4495.                                                        
  4496.                                                         Z = Z + (Blocks + 1)
  4497.                                                        
  4498.                                                     end
  4499.                                                    
  4500.                                                 end
  4501.                                                
  4502.                                             end
  4503.                                            
  4504.                                         elseif Ax == string.lower("z") and Way == string.lower("min") then
  4505.                                            
  4506.                                             for i = 1, #Turtles do
  4507.                                                
  4508.                                                 if Turtles[i].GroupState == true then
  4509.                                                    
  4510.                                                     sleep(5)
  4511.                                                    
  4512.                                                     local Data = {What = "Command", Command = "QuArry", Data = {X = TargetX, Y = TargetY, Z = TargetZ, Blocks = Blocks, Lines = Lines, Layers = Layers}}
  4513.                                                    
  4514.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4515.                                                    
  4516.                                                     if Between ~= 0 and Between ~= nil then
  4517.                                                        
  4518.                                                         Z = Z - (Blocks + 1) - Between
  4519.                                                        
  4520.                                                     else
  4521.                                                        
  4522.                                                         Z = Z - (Blocks + 1)
  4523.                                                        
  4524.                                                     end
  4525.                                                    
  4526.                                                 end
  4527.                                                
  4528.                                             end
  4529.                                            
  4530.                                         end
  4531.                                        
  4532.                                     else
  4533.                                        
  4534.                                         Monitor[0].clear()
  4535.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "One Moment Please...")
  4536.                                        
  4537.                                         local Data = {What = "Command", Command = "/QuArry/", Data = {X = X, Y = Y, Z = Z, Blocks = Blocks, Lines = Lines, Layers = Layers}}
  4538.                                        
  4539.                                         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4540.                                        
  4541.                                     end
  4542.                                    
  4543.                                 elseif nTurtleProgramsOption == 2 then
  4544.                                    
  4545.                                     Monitor[0].clear()
  4546.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry X: ")
  4547.                                     local X = tonumber(read())
  4548.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry Y: ")
  4549.                                     local Y = tonumber(read())
  4550.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry Z: ")
  4551.                                     local Z = tonumber(read())
  4552.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "1 = North, 2 = East, 3 = South, 4 = West: ")
  4553.                                     local R = tonumber(read())
  4554.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Blocks (front): ")
  4555.                                     local Blocks = tonumber(read())
  4556.                                    
  4557.                                     if Computer.Connection.ConnectedTurtle.Id == Computer.System.Modem.SharedID then
  4558.                                        
  4559.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "On x (E/W) or on Y (Up/Down) or on z (N/S) ax: ")
  4560.                                         local Ax = tonumber(read())
  4561.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "plus (S/E) or min (N/W): ")
  4562.                                         local Way = tonumber(read())
  4563.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "How many between: ")
  4564.                                         local Between = tonumber(read())
  4565.                                        
  4566.                                         Monitor[0].clear()
  4567.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "One Moment Please...")
  4568.                                        
  4569.                                         if Ax == string.lower("x") and Way == string.lower("plus") then
  4570.                                            
  4571.                                             for i = 1, #Turtles do
  4572.                                                
  4573.                                                 if Turtles[i].GroupState == true then
  4574.                                                    
  4575.                                                     sleep(5)
  4576.                                                    
  4577.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  4578.                                                    
  4579.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4580.                                                    
  4581.                                                     if Between ~= 0 and Between ~= nil then
  4582.                                                        
  4583.                                                         X = X + 3 + Between
  4584.                                                        
  4585.                                                     else
  4586.                                                        
  4587.                                                         X = X + 3
  4588.                                                        
  4589.                                                     end
  4590.                                                    
  4591.                                                 end
  4592.                                                
  4593.                                             end
  4594.                                            
  4595.                                         elseif Ax == string.lower("x") and Way == string.lower("min") then
  4596.                                            
  4597.                                             for i = 1, #Turtles do
  4598.                                                
  4599.                                                 if Turtles[i].GroupState == true then
  4600.                                                    
  4601.                                                     sleep(5)
  4602.                                                    
  4603.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  4604.                                                    
  4605.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4606.                                                    
  4607.                                                     if Between ~= 0 and Between ~= nil then
  4608.                                                        
  4609.                                                         X = X - 3 - Between
  4610.                                                        
  4611.                                                     else
  4612.                                                        
  4613.                                                         X = X - 3
  4614.                                                        
  4615.                                                     end
  4616.                                                    
  4617.                                                 end
  4618.                                                
  4619.                                             end
  4620.                                            
  4621.                                         elseif Ax == string.lower("z") and Way == string.lower("plus") then
  4622.                                            
  4623.                                             for i = 1, #Turtles do
  4624.                                                
  4625.                                                 if Turtles[i].GroupState == true then
  4626.                                                    
  4627.                                                     sleep(5)
  4628.                                                    
  4629.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  4630.                                                    
  4631.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4632.                                                    
  4633.                                                     if Between ~= 0 and Between ~= nil then
  4634.                                                        
  4635.                                                         Z = Z + 3 + Between
  4636.                                                        
  4637.                                                     else   
  4638.                                                        
  4639.                                                         Z = Z + 3
  4640.                                                        
  4641.                                                     end
  4642.                                                    
  4643.                                                 end
  4644.                                                
  4645.                                             end
  4646.                                            
  4647.                                         elseif Ax == string.lower("z") and Way == string.lower("min") then
  4648.                                            
  4649.                                             for i = 1, #Turtles do
  4650.                                                
  4651.                                                 if Turtles[i].GroupState == true then
  4652.                                                    
  4653.                                                     sleep(5)
  4654.                                                    
  4655.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  4656.                                                    
  4657.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4658.                                                    
  4659.                                                     if Between ~= 0 and Between ~= nil then
  4660.                                                        
  4661.                                                         Z = Z - 3 - Between
  4662.                                                        
  4663.                                                     else
  4664.                                                        
  4665.                                                         Z = Z - 3
  4666.                                                        
  4667.                                                     end
  4668.                                                    
  4669.                                                 end
  4670.                                                
  4671.                                             end
  4672.                                            
  4673.                                         elseif Ax == string.lower("y") and Way == string.lower("plus") then
  4674.                                            
  4675.                                             for i = 1, #Turtles do
  4676.                                                
  4677.                                                 if Turtles[i].GroupState == true then
  4678.                                                    
  4679.                                                     sleep(5)
  4680.                                                    
  4681.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  4682.                                                    
  4683.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4684.                                                    
  4685.                                                     if Between ~= 0 and Between ~= nil then
  4686.                                                        
  4687.                                                         Y = Y + 3 + Between
  4688.                                                        
  4689.                                                     else   
  4690.                                                        
  4691.                                                         Y = Y + 3
  4692.                                                        
  4693.                                                     end
  4694.                                                    
  4695.                                                 end
  4696.                                                
  4697.                                             end
  4698.                                            
  4699.                                         elseif Ax == string.lower("y") and Way == string.lower("min") then
  4700.                                            
  4701.                                             for i = 1, #Turtles do
  4702.                                                
  4703.                                                 if Turtles[i].GroupState == true then
  4704.                                                    
  4705.                                                     sleep(5)
  4706.                                                    
  4707.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  4708.                                                    
  4709.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4710.                                                    
  4711.                                                     if Between ~= 0 and Between ~= nil then
  4712.                                                        
  4713.                                                         Y = Y - 3 - Between
  4714.                                                        
  4715.                                                     else
  4716.                                                        
  4717.                                                         Y = Y - 3
  4718.                                                        
  4719.                                                     end
  4720.                                                    
  4721.                                                 end
  4722.                                                
  4723.                                             end
  4724.                                            
  4725.                                         end
  4726.                                        
  4727.                                     else
  4728.                                        
  4729.                                         Monitor[0].clear()
  4730.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "One Moment Please...")
  4731.                                        
  4732.                                         local Data = {What = "Command", Command = "/TuNnel/", Data = {X = X, Y = Y, Z = Z, R = R, Blocks = Blocks}}
  4733.                                        
  4734.                                         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4735.                                        
  4736.                                     end
  4737.                                    
  4738.                                 elseif nTurtleProgramsOption == 3 then
  4739.                                    
  4740.                                     if Computer.Connection.ConnectedTurtle.Id ~= Computer.System.Modem.SharedID then
  4741.                                        
  4742.                                         local Data = {What = "Command", Command = "/3DPrint/"}
  4743.                                        
  4744.                                         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4745.                                        
  4746.                                         shell.run("/Progs/3DPaintPro.lua")
  4747.                                        
  4748.                                     end
  4749.                                    
  4750.                                 elseif nTurtleProgramsOption == 4 then
  4751.                                    
  4752.                                     local Data = {What = "Command", Command = "/FaRm/"}
  4753.                                    
  4754.                                     local timerUpdate = System.startTimer(Temp.FarmTimer)
  4755.                                     local AState = true
  4756.                                     local i = 1
  4757.                                    
  4758.                                     while Turtles[i].GroupState == false or Turtles[i].Status == false do
  4759.                                        
  4760.                                         i = i + 1
  4761.                                        
  4762.                                         if i > #Turtles then
  4763.                                            
  4764.                                             i = 1
  4765.                                            
  4766.                                         end
  4767.                                        
  4768.                                     end
  4769.                                    
  4770.                                     while AState do
  4771.                                        
  4772.                                         WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4773.                                        
  4774.                                         Monitor[0].clear()
  4775.                                        
  4776.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "Press any key to end.")
  4777.                                        
  4778.                                         local event, param1, param2, param3, param4, param5 = System.pullEvent()
  4779.                                        
  4780.                                         if (event == "timer") then
  4781.                                            
  4782.                                             if (param1 == timerUpdate) then
  4783.                                                
  4784.                                                 checkForTurtles()
  4785.                                                
  4786.                                                 i = i + 1
  4787.                                                
  4788.                                                 if i > #Turtles then
  4789.                                                    
  4790.                                                     i = 1
  4791.                                                    
  4792.                                                 end
  4793.                                                
  4794.                                                 while Turtles[i].GroupState == false or Turtles[i].Status == false do
  4795.                                                    
  4796.                                                     i = i + 1
  4797.                                                    
  4798.                                                     if i > #Turtles then
  4799.                                                        
  4800.                                                         i = 1
  4801.                                                        
  4802.                                                     end
  4803.                                                    
  4804.                                                 end
  4805.                                                
  4806.                                                 WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4807.                                                
  4808.                                                 timerUpdate = System.startTimer(Temp.FarmTimer)
  4809.                                                
  4810.                                             end
  4811.                                            
  4812.                                         end
  4813.                                        
  4814.                                         if (event == "key") then
  4815.                                            
  4816.                                             System.cancelTimer(timerUpdate)
  4817.                                            
  4818.                                             AState = false
  4819.                                            
  4820.                                         end
  4821.                                        
  4822.                                     end
  4823.                                    
  4824.                                 elseif nTurtleProgramsOption == 5 then
  4825.                                    
  4826.                                     local Data = {What = "Command", Command = "/L04DTR33F4RM/"}
  4827.                                    
  4828.                                     WModem.Send(Computer.System.Modem.ServerID, Computer.System.Modem.OwnID, Pack(Data))
  4829.                                    
  4830.                                     local Event, p1, p2, p3, p4, p5 = System.pullEvent("modem_message")
  4831.                                    
  4832.                                     TreeFarms = UnPack(p4)
  4833.                                    
  4834.                                     Monitor[0].clear()
  4835.                                    
  4836.                                     local n
  4837.                                    
  4838.                                     for i = 1, #TreeFarms do
  4839.                                        
  4840.                                         Functions.printCentered(Monitor[0], i, i.." = Farm"..i.." X: "..TreeFarms[i].X.." Y: "..TreeFarms[i].Y.." Z: "..TreeFarms[i].Z)
  4841.                                        
  4842.                                         n = i
  4843.                                        
  4844.                                     end
  4845.                                    
  4846.                                     Functions.printCentered(Monitor[0], n + 1, "Number: ")
  4847.                                    
  4848.                                     local Number = tonumber(read())
  4849.                                    
  4850.                                     Data = {What = "Command", Command = "/TreeFarm/", Data = TreeFarms[Number]}
  4851.                                    
  4852.                                     WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  4853.                                    
  4854.                                 end
  4855.                                
  4856.                             else
  4857.                                
  4858.                                 if nTurtleProgramsOption == 1 then
  4859.                                    
  4860.                                     Monitor[0].clear()
  4861.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry X: ")
  4862.                                     local X = tonumber(read())
  4863.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry Y: ")
  4864.                                     local Y = tonumber(read())
  4865.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry Z: ")
  4866.                                     local Z = tonumber(read())
  4867.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Blocks (front): ")
  4868.                                     local Blocks = tonumber(read())
  4869.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Lines (side): ")
  4870.                                     local Lines = tonumber(read())
  4871.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Layers (down): ")
  4872.                                     local Layers = tonumber(read())
  4873.                                    
  4874.                                     if Computer.Connection.ConnectedTurtle.Id == Computer.System.Modem.SharedID then
  4875.                                        
  4876.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "On x (E/W) or on z (N/S) ax: ")
  4877.                                         local Ax = tonumber(read())
  4878.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "plus (S/E) or min (N/W): ")
  4879.                                         local Way = tonumber(read())
  4880.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "How many between: ")
  4881.                                         local Between = tonumber(read())
  4882.                                        
  4883.                                         Monitor[0].clear()
  4884.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "One Moment Please...")
  4885.                                        
  4886.                                         if Ax == string.lower("x") and Way == string.lower("plus") then
  4887.                                            
  4888.                                             for i = 1, #Turtles do
  4889.                                                
  4890.                                                 if Turtles[i].GroupState == true then
  4891.                                                    
  4892.                                                     sleep(5)
  4893.                                                    
  4894.                                                     local Data = {What = "Command", Command = "QuArry", Data = {X = TargetX, Y = TargetY, Z = TargetZ, Blocks = Blocks, Lines = Lines, Layers = Layers}}
  4895.                                                    
  4896.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4897.                                                    
  4898.                                                     if Between ~= 0 and Between ~= nil then
  4899.                                                        
  4900.                                                         X = X + Lines + Between
  4901.                                                        
  4902.                                                     else
  4903.                                                        
  4904.                                                         X = X + Lines
  4905.                                                        
  4906.                                                     end
  4907.                                                    
  4908.                                                 end
  4909.                                                
  4910.                                             end
  4911.                                            
  4912.                                         elseif Ax == string.lower("x") and Way == string.lower("min") then
  4913.                                            
  4914.                                             for i = 1, #Turtles do
  4915.                                                
  4916.                                                 if Turtles[i].GroupState == true then
  4917.                                                    
  4918.                                                     sleep(5)
  4919.                                                    
  4920.                                                     local Data = {What = "Command", Command = "QuArry", Data = {X = TargetX, Y = TargetY, Z = TargetZ, Blocks = Blocks, Lines = Lines, Layers = Layers}}
  4921.                                                    
  4922.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4923.                                                    
  4924.                                                     if Between ~= 0 and Between ~= nil then
  4925.                                                        
  4926.                                                         X = X - Lines - Between
  4927.                                                        
  4928.                                                     else
  4929.                                                        
  4930.                                                         X = X - Lines
  4931.                                                        
  4932.                                                     end
  4933.                                                    
  4934.                                                 end
  4935.                                                
  4936.                                             end
  4937.                                            
  4938.                                         elseif Ax == string.lower("z") and Way == string.lower("plus") then
  4939.                                            
  4940.                                             for i = 1, #Turtles do
  4941.                                                
  4942.                                                 if Turtles[i].GroupState == true then
  4943.                                                    
  4944.                                                     sleep(5)
  4945.                                                    
  4946.                                                     local Data = {What = "Command", Command = "QuArry", Data = {X = TargetX, Y = TargetY, Z = TargetZ, Blocks = Blocks, Lines = Lines, Layers = Layers}}
  4947.                                                    
  4948.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4949.                                                    
  4950.                                                     if Between ~= 0 and Between ~= nil then
  4951.                                                        
  4952.                                                         Z = Z + (Blocks + 1) + Between
  4953.                                                        
  4954.                                                     else   
  4955.                                                        
  4956.                                                         Z = Z + (Blocks + 1)
  4957.                                                        
  4958.                                                     end
  4959.                                                    
  4960.                                                 end
  4961.                                                
  4962.                                             end
  4963.                                            
  4964.                                         elseif Ax == string.lower("z") and Way == string.lower("min") then
  4965.                                            
  4966.                                             for i = 1, #Turtles do
  4967.                                                
  4968.                                                 if Turtles[i].GroupState == true then
  4969.                                                    
  4970.                                                     sleep(5)
  4971.                                                    
  4972.                                                     local Data = {What = "Command", Command = "QuArry", Data = {X = TargetX, Y = TargetY, Z = TargetZ, Blocks = Blocks, Lines = Lines, Layers = Layers}}
  4973.                                                    
  4974.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  4975.                                                    
  4976.                                                     if Between ~= 0 and Between ~= nil then
  4977.                                                        
  4978.                                                         Z = Z - (Blocks + 1) - Between
  4979.                                                        
  4980.                                                     else
  4981.                                                        
  4982.                                                         Z = Z - (Blocks + 1)
  4983.                                                        
  4984.                                                     end
  4985.                                                    
  4986.                                                 end
  4987.                                                
  4988.                                             end
  4989.                                            
  4990.                                         end
  4991.                                        
  4992.                                     else
  4993.                                        
  4994.                                         Monitor[0].clear()
  4995.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "One Moment Please...")
  4996.                                        
  4997.                                         local Data = {What = "Command", Command = "/QuArry/", Data = {X = X, Y = Y, Z = Z, Blocks = Blocks, Lines = Lines, Layers = Layers}}
  4998.                                        
  4999.                                         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  5000.                                        
  5001.                                     end
  5002.                                    
  5003.                                 elseif nTurtleProgramsOption == 2 then
  5004.                                    
  5005.                                     Monitor[0].clear()
  5006.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry X: ")
  5007.                                     local X = tonumber(read())
  5008.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry Y: ")
  5009.                                     local Y = tonumber(read())
  5010.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Quarry Z: ")
  5011.                                     local Z = tonumber(read())
  5012.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "1 = North, 2 = East, 3 = South, 4 = West: ")
  5013.                                     local R = tonumber(read())
  5014.                                     Functions.printCentered(Monitor[0], math.floor(h/2), "Blocks (front): ")
  5015.                                     local Blocks = tonumber(read())
  5016.                                    
  5017.                                     if Computer.Connection.ConnectedTurtle.Id == Computer.System.Modem.SharedID then
  5018.                                        
  5019.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "On x (E/W) or on Y (Up/Down) or on z (N/S) ax: ")
  5020.                                         local Ax = tonumber(read())
  5021.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "plus (S/E) or min (N/W): ")
  5022.                                         local Way = tonumber(read())
  5023.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "How many between: ")
  5024.                                         local Between = tonumber(read())
  5025.                                        
  5026.                                         Monitor[0].clear()
  5027.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "One Moment Please...")
  5028.                                        
  5029.                                         if Ax == string.lower("x") and Way == string.lower("plus") then
  5030.                                            
  5031.                                             for i = 1, #Turtles do
  5032.                                                
  5033.                                                 if Turtles[i].GroupState == true then
  5034.                                                    
  5035.                                                     sleep(5)
  5036.                                                    
  5037.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  5038.                                                    
  5039.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  5040.                                                    
  5041.                                                     if Between ~= 0 and Between ~= nil then
  5042.                                                        
  5043.                                                         X = X + 3 + Between
  5044.                                                        
  5045.                                                     else
  5046.                                                        
  5047.                                                         X = X + 3
  5048.                                                        
  5049.                                                     end
  5050.                                                    
  5051.                                                 end
  5052.                                                
  5053.                                             end
  5054.                                            
  5055.                                         elseif Ax == string.lower("x") and Way == string.lower("min") then
  5056.                                            
  5057.                                             for i = 1, #Turtles do
  5058.                                                
  5059.                                                 if Turtles[i].GroupState == true then
  5060.                                                    
  5061.                                                     sleep(5)
  5062.                                                    
  5063.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  5064.                                                    
  5065.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  5066.                                                    
  5067.                                                     if Between ~= 0 and Between ~= nil then
  5068.                                                        
  5069.                                                         X = X - 3 - Between
  5070.                                                        
  5071.                                                     else
  5072.                                                        
  5073.                                                         X = X - 3
  5074.                                                        
  5075.                                                     end
  5076.                                                    
  5077.                                                 end
  5078.                                                
  5079.                                             end
  5080.                                            
  5081.                                         elseif Ax == string.lower("z") and Way == string.lower("plus") then
  5082.                                            
  5083.                                             for i = 1, #Turtles do
  5084.                                                
  5085.                                                 if Turtles[i].GroupState == true then
  5086.                                                    
  5087.                                                     sleep(5)
  5088.                                                    
  5089.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  5090.                                                    
  5091.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  5092.                                                    
  5093.                                                     if Between ~= 0 and Between ~= nil then
  5094.                                                        
  5095.                                                         Z = Z + 3 + Between
  5096.                                                        
  5097.                                                     else   
  5098.                                                        
  5099.                                                         Z = Z + 3
  5100.                                                        
  5101.                                                     end
  5102.                                                    
  5103.                                                 end
  5104.                                                
  5105.                                             end
  5106.                                            
  5107.                                         elseif Ax == string.lower("z") and Way == string.lower("min") then
  5108.                                            
  5109.                                             for i = 1, #Turtles do
  5110.                                                
  5111.                                                 if Turtles[i].GroupState == true then
  5112.                                                    
  5113.                                                     sleep(5)
  5114.                                                    
  5115.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  5116.                                                    
  5117.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  5118.                                                    
  5119.                                                     if Between ~= 0 and Between ~= nil then
  5120.                                                        
  5121.                                                         Z = Z - 3 - Between
  5122.                                                        
  5123.                                                     else
  5124.                                                        
  5125.                                                         Z = Z - 3
  5126.                                                        
  5127.                                                     end
  5128.                                                    
  5129.                                                 end
  5130.                                                
  5131.                                             end
  5132.                                            
  5133.                                         elseif Ax == string.lower("y") and Way == string.lower("plus") then
  5134.                                            
  5135.                                             for i = 1, #Turtles do
  5136.                                                
  5137.                                                 if Turtles[i].GroupState == true then
  5138.                                                    
  5139.                                                     sleep(5)
  5140.                                                    
  5141.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  5142.                                                    
  5143.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  5144.                                                    
  5145.                                                     if Between ~= 0 and Between ~= nil then
  5146.                                                        
  5147.                                                         Y = Y + 3 + Between
  5148.                                                        
  5149.                                                     else   
  5150.                                                        
  5151.                                                         Y = Y + 3
  5152.                                                        
  5153.                                                     end
  5154.                                                    
  5155.                                                 end
  5156.                                                
  5157.                                             end
  5158.                                            
  5159.                                         elseif Ax == string.lower("y") and Way == string.lower("min") then
  5160.                                            
  5161.                                             for i = 1, #Turtles do
  5162.                                                
  5163.                                                 if Turtles[i].GroupState == true then
  5164.                                                    
  5165.                                                     sleep(5)
  5166.                                                    
  5167.                                                     local Data = {What = "Command", Command = "TuNnel", Data = {X = TargetX, Y = TargetY, Z = TargetZ, R = R, Blocks = Blocks}}
  5168.                                                    
  5169.                                                     WModem.Send(Turtles[i].Id, Computer.System.Modem.OwnID, Pack(Data))
  5170.                                                    
  5171.                                                     if Between ~= 0 and Between ~= nil then
  5172.                                                        
  5173.                                                         Y = Y - 3 - Between
  5174.                                                        
  5175.                                                     else
  5176.                                                        
  5177.                                                         Y = Y - 3
  5178.                                                        
  5179.                                                     end
  5180.                                                    
  5181.                                                 end
  5182.                                                
  5183.                                             end
  5184.                                            
  5185.                                         end
  5186.                                        
  5187.                                     else
  5188.                                        
  5189.                                         Monitor[0].clear()
  5190.                                         Functions.printCentered(Monitor[0], math.floor(h/2), "One Moment Please...")
  5191.                                        
  5192.                                         local Data = {What = "Command", Command = "/TuNnel/", Data = {X = X, Y = Y, Z = Z, R = R, Blocks = Blocks}}
  5193.                                        
  5194.                                         WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  5195.                                        
  5196.                                     end
  5197.                                    
  5198.                                 elseif nTurtleProgramsOption == 3 then
  5199.                                    
  5200.                                     local Data = {What = "Command", Command = "/3DPrint/"}
  5201.                                    
  5202.                                     WModem.Send(Computer.Connection.ConnectedTurtle.Id, Computer.System.Modem.OwnID, Pack(Data))
  5203.                                    
  5204.                                     shell.run("/Progs/3DPaintPro.lua")
  5205.                                    
  5206.                                 end
  5207.                                
  5208.                             end
  5209.                            
  5210.                         elseif p1 == keys.b then
  5211.                            
  5212.                             Back = true
  5213.                            
  5214.                         end
  5215.                     end
  5216.                    
  5217.                 end
  5218.                
  5219.             end
  5220.            
  5221.         end
  5222.        
  5223.     else
  5224.        
  5225.         if nOption == 1 then
  5226.            
  5227.             -- System
  5228.            
  5229.             nSystemOption = 1
  5230.            
  5231.             local Back = false
  5232.            
  5233.             Monitor[0].clear()
  5234.             Monitor[0].setCursorPos(1, 1)
  5235.            
  5236.             while not(Back) do
  5237.                
  5238.                 drawSystemMenu()
  5239.                 drawSystemFrontend()
  5240.                
  5241.                 local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  5242.                
  5243.                 if Event == "key" then
  5244.                    
  5245.                     if p1 == keys.up or p1 == keys.numPad8 then
  5246.                        
  5247.                         if nSystemOption > 1 then
  5248.                            
  5249.                             nSystemOption = nSystemOption - 1
  5250.                            
  5251.                         end
  5252.                        
  5253.                     elseif p1 == keys.down or p1 == keys.numPad2 then
  5254.                        
  5255.                         if nSystemOption < MaxSystemOptions then
  5256.                            
  5257.                             nSystemOption = nSystemOption + 1
  5258.                            
  5259.                         end
  5260.                        
  5261.                     elseif p1 == keys.enter or p1 == keys.numPadEnter then
  5262.                        
  5263.                         if nSystemOption == 1 then
  5264.                            
  5265.                             -- Connection turtle
  5266.                            
  5267.                             MaxTurtlesOptions = #Turtles
  5268.                             nTurtlesOption = 1
  5269.                            
  5270.                             local TurtlesBack = false
  5271.                            
  5272.                             Monitor[0].clear()
  5273.                             Monitor[0].setCursorPos(1, 1)
  5274.                            
  5275.                             while not(TurtlesBack) do
  5276.                                
  5277.                                 drawTurtlesFrontend()
  5278.                                
  5279.                                 local Event, p1, p2, p3 = System.pullEvent()
  5280.                                
  5281.                                 if Event == "key" then
  5282.                                    
  5283.                                     if p1 == keys.up or p1 == keys.numPad8 then
  5284.                                        
  5285.                                         if nTurtlesOption > 1 then
  5286.                                            
  5287.                                             nTurtlesOption = nTurtlesOption - 1
  5288.                                            
  5289.                                         end
  5290.                                        
  5291.                                     elseif p1 == keys.down or p1 == keys.numPad2 then
  5292.                                        
  5293.                                         if nTurtlesOption < MaxTurtlesOptions then
  5294.                                            
  5295.                                             nTurtlesOption = nTurtlesOption + 1
  5296.                                            
  5297.                                         end
  5298.                                        
  5299.                                     elseif p1 == keys.enter or p1 == keys.numPadEnter then
  5300.                                        
  5301.                                         -- Turtles
  5302.                                        
  5303.                                         for i = 1, #Turtles do
  5304.                                            
  5305.                                             SendInfo(Turtles[i].Id, "Function", "StripMineDone")
  5306.                                             sleep(1)
  5307.                                             SendInfo(Turtles[i].Id, "Function", "NR")
  5308.                                            
  5309.                                         end
  5310.                                        
  5311.                                         Computer.Connection.ConnectedID = Turtles[nTurtlesOption].Id
  5312.                                         Computer.Connection.ConnectedTurtle = Turtles[nTurtlesOption]
  5313.                                        
  5314.                                         if Monitor then
  5315.                                            
  5316.                                             ConfigInventoryBottons()
  5317.                                             ConfigMonitor()
  5318.                                            
  5319.                                         end
  5320.                                        
  5321.                                         if pocket then
  5322.                                            
  5323.                                             ButtonForward = Button.setButton("W", Move, 4, 6, 7, 9, true, "forward")
  5324.                                             ButtonBack = Button.setButton("S", Move, 4, 6, 10, 12, true, "back")
  5325.                                             ButtonLeft = Button.setButton("A", Move, 1, 3, 10, 12, true, "left")
  5326.                                             ButtonRight = Button.setButton("D", Move, 7, 9, 10, 12, true, "right")
  5327.                                             ButtonUp = Button.setButton("R", Move, 2, 4, 14, 16, true, "up")
  5328.                                             ButtonDown = Button.setButton("F", Move, 6, 8, 14, 16, true, "down")
  5329.                                            
  5330.                                         else
  5331.                                            
  5332.                                             ButtonForward = Button.setButton("W", Move, 11, 13, 11, 13, true, "forward")
  5333.                                             ButtonBack = Button.setButton("S", Move, 11, 13, 14, 16, true, "back")
  5334.                                             ButtonLeft = Button.setButton("A", Move, 8, 10, 14, 16, true, "left")
  5335.                                             ButtonRight = Button.setButton("D", Move, 14, 16, 14, 16, true, "right")
  5336.                                             ButtonUp = Button.setButton("R", Move, 18, 20, 11, 13, true, "up")
  5337.                                             ButtonDown = Button.setButton("F", Move, 18, 20, 14, 16, true, "down")
  5338.                                            
  5339.                                         end
  5340.                                        
  5341.                                         Computer.Connection.Connected = true
  5342.                                         TurtlesBack = true
  5343.                                         Back = true
  5344.                                        
  5345.                                     elseif p1 == keys.b then
  5346.                                        
  5347.                                         TurtlesBack = true
  5348.                                        
  5349.                                     end
  5350.                                    
  5351.                                 end
  5352.                                
  5353.                             end
  5354.                            
  5355.                         elseif nSystemOption == 2 then
  5356.                            
  5357.                             -- Reboot
  5358.                            
  5359.                             SaveSettings()
  5360.                             System.reboot()
  5361.                            
  5362.                         elseif nSystemOption == 3 then
  5363.                            
  5364.                             -- Reset
  5365.                            
  5366.                             Monitor[0].clear()
  5367.                             Functions.printCentered(Monitor[0], math.floor(h/2), "Rest Computer? ... Y/N")
  5368.                            
  5369.                             local Event, p1, p2, p3 = System.pullEvent("key")
  5370.                            
  5371.                             if p1 == keys.y then
  5372.                                
  5373.                                 local File = fs.exists("/Progs/.Data/.Settings.set", "r")
  5374.                                
  5375.                                 if File then
  5376.                                    
  5377.                                     Functions.DelFile("/Progs/.Data/.Settings.set")
  5378.                                    
  5379.                                 end
  5380.                                
  5381.                                 System.reboot()
  5382.                                
  5383.                             end
  5384.                            
  5385.                         elseif nSystemOption == 4 then
  5386.                            
  5387.                             Monitor[0].clear()
  5388.                             Functions.printCentered(Monitor[0], math.floor(h/2), "Run Uninstaller? ... Y/N")
  5389.                            
  5390.                             local Event, p1, p2, p3 = System.pullEvent("key")
  5391.                            
  5392.                             if p1 == keys.y then
  5393.                                
  5394.                                 shell.run("/OS/Unintall.lua")
  5395.                                
  5396.                             end
  5397.                            
  5398.                         end
  5399.                        
  5400.                     elseif p1 == keys.b then
  5401.                        
  5402.                         Back = true
  5403.                        
  5404.                     end
  5405.                    
  5406.                 end
  5407.                
  5408.             end
  5409.            
  5410.         end
  5411.        
  5412.     end
  5413.    
  5414. end
  5415.  
  5416. function MonitorTouched(MX, MY)
  5417.    
  5418.     checkForTurtles()
  5419.    
  5420.     for i = 1, #Turtles do
  5421.        
  5422.         if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  5423.            
  5424.             Computer.Connection.ConnectedTurtle = Turtles[i]
  5425.            
  5426.         end
  5427.        
  5428.     end
  5429.    
  5430.     if nMonitorOption == 3 and Computer.Connection.ConnectedTurtle.Status then
  5431.        
  5432.         MStripMineButton.buttonPressed(MX, MY)
  5433.        
  5434.     end
  5435.    
  5436.     if nMonitorOption == 2 and Computer.Connection.ConnectedTurtle.Status then
  5437.        
  5438.         MINVButton.buttonPressed(MX, MY)
  5439.        
  5440.     end
  5441.    
  5442.     MMenuButton.buttonPressed(MX, MY)
  5443.    
  5444.     if MButtonn and Computer.Connection.ConnectedTurtle.Status then
  5445.        
  5446.         MMoveButton.buttonPressed(MX, MY)
  5447.        
  5448.     end
  5449.    
  5450.     sleep(1)
  5451.    
  5452.     checkForTurtles()
  5453.    
  5454.     for i = 1, #Turtles do
  5455.        
  5456.         if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  5457.            
  5458.             Computer.Connection.ConnectedTurtle = Turtles[i]
  5459.            
  5460.         end
  5461.        
  5462.     end
  5463.    
  5464. end
  5465.  
  5466. Monitor[0].clear()
  5467. Monitor[0].setCursorPos(1, 1)
  5468.  
  5469. Startup()
  5470.  
  5471. while Computer.System.Status do
  5472.    
  5473.     Timer[1] = System.startTimer(5)
  5474.    
  5475.     checkForTurtles()
  5476.    
  5477.     if Monitor then
  5478.        
  5479.         drawMonitor()
  5480.        
  5481.     end
  5482.    
  5483.     drawMenu()
  5484.     drawFrontend()
  5485.  
  5486.     local Event, p1, p2, p3, p4, p5 = System.pullEvent()
  5487.    
  5488.     if Event == "key" then
  5489.        
  5490.         System.cancelTimer(Timer[1])
  5491.        
  5492.         if p1 == keys.up or p1 == keys.numPad8 then
  5493.            
  5494.             if Computer.Connection.Connected then
  5495.                
  5496.                 if nOption > 1 then
  5497.                    
  5498.                     nOption = nOption - 1
  5499.                    
  5500.                 end
  5501.                
  5502.             end
  5503.            
  5504.         elseif p1 == keys.down or p1 == keys.numPad2 then
  5505.            
  5506.             if Computer.Connection.Connected then
  5507.                
  5508.                 if nOption < MaxOptions then
  5509.                    
  5510.                     nOption = nOption + 1
  5511.                    
  5512.                 end
  5513.                
  5514.             end
  5515.            
  5516.         elseif p1 == keys.enter or p1 == keys.numPadEnter then
  5517.            
  5518.             if Monitor then
  5519.                
  5520.                 Monitor[1].clear()
  5521.                 Monitor[1].setCursorPos(1, 1)
  5522.                
  5523.             end
  5524.            
  5525.             onEnter()
  5526.            
  5527.         elseif p1 == keys.slash then
  5528.            
  5529.             if Monitor then
  5530.                
  5531.                 Monitor[1].clear()
  5532.                 Monitor[1].setCursorPos(1, 1)
  5533.                
  5534.             end
  5535.            
  5536.             Computer.System.Status = false
  5537.            
  5538.         elseif p1 == keys.q then
  5539.            
  5540.             if Monitor[1] then
  5541.                
  5542.                 Monitor[1].clear()
  5543.                 Monitor[1].setCursorPos(1, 1)
  5544.                
  5545.             end
  5546.            
  5547.             SaveSettings()
  5548.             Computer.System.Status = false
  5549.            
  5550.         end
  5551.        
  5552.     elseif Event == "monitor_touch"then
  5553.        
  5554.         System.cancelTimer(Timer[1])
  5555.        
  5556.         if Computer.Connection.Connected then
  5557.            
  5558.             local Button, MX, MY = p1, p2, p3
  5559.            
  5560.             MonitorTouched(MX, MY)
  5561.            
  5562.         end
  5563.        
  5564.     elseif Event == "monitor_resize"then
  5565.        
  5566.         System.cancelTimer(Timer[1])
  5567.        
  5568.         TestMonitor()
  5569.        
  5570.         if Computer.Connection.Connected then
  5571.            
  5572.             ConfigInventoryBottons()
  5573.             ConfigMonitor()
  5574.             nMonitorOption = 0
  5575.             MButtonn = false
  5576.             ButtonInfo = false
  5577.             ButtonInventory = false
  5578.             ButtonQuarry2 = false
  5579.            
  5580.         end
  5581.        
  5582.     elseif Event == "timer" then
  5583.        
  5584.         System.cancelTimer(Timer[1])
  5585.        
  5586.         checkForTurtles()
  5587.        
  5588.         for i = 1, #Turtles do
  5589.            
  5590.             if Turtles[i].Id == Computer.Connection.ConnectedTurtle.Id then
  5591.                
  5592.                 Computer.Connection.ConnectedTurtle = Turtles[i]
  5593.                
  5594.             end
  5595.            
  5596.         end
  5597.        
  5598.     else
  5599.        
  5600.         System.cancelTimer(Timer[1])
  5601.        
  5602.     end
  5603.    
  5604. end
  5605.  
  5606. Functions.SetColors(Monitor[0], Color.Black, Color.White)
  5607. Monitor[0].clear()
  5608. Monitor[0].setCursorPos(1, 1)
Add Comment
Please, Sign In to add comment