Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Version = "1.0.4"
- -- // so GPS computer and Server gets time to start up first ( do not remove or put it below 3 sec. )
- sleep(math.random(3, 6)) -- // (Random is for if there are more then 1 turtle.)
- -- // Cant Message all at same time for GPS or LogIn on Server, so leave the sleep(math.random(+3, 10-))
- -- Locals
- local System = os -- Used for System things like os.time() to System.time()
- local Screen = term -- Used for Screen thing on the turtle or computer like term.clear() to Screen.clear()
- local Per = peripheral -- Used shortcut for peripheral
- local Text = textutils -- Used shortcut for textilils
- local Pack = Text.serialize -- Makes a new command for packing ( shortcut used from local Text)
- local UnPack = Text.unserialize -- Makes a new command for unpacking ( shortcut used from local Text)
- local file = fs.exists("/OS/.Data/Button.lua")
- if not(file) then
- shell.run("pastebin get UV1jWtan /OS/.Data/Button.lua")
- end
- local file = fs.exists("/OS/.Data/.OreLib.txt")
- if not(file) then
- shell.run("pastebin get f8Pw0Ya2 /OS/.Data/.OreLib.txt")
- end
- file = fs.open("/OS/.Data/.OreLib.txt", "r")
- local OreLib = UnPack(file.readAll())
- file.close()
- System.loadAPI("/OS/.Data/Button.lua")
- local OldpullEvent = System.pullEvent
- local Pers = {}
- local Modem
- local Send
- local Monitor
- local Blocks = {
- Dirt = "minecraft:dirt",
- Grass = "minecraft:grass_block",
- FarmGround = "minecraft:farmland",
- Water = "minecraft:water_bucket",
- SoulSand = "minecraft:soul_sand"
- }
- local Plant = {
- Wheat = {name = "minecraft:wheat", age = 7, seed = "minecraft:wheat_seeds"},
- Beetroot = {name = "minecraft:beetroots", age = 3, seed = "minecraft:beetroot_seeds"},
- Carrot = {name = "minecraft:carrots", age = 7, seed = "minecraft:carrot"},
- Potato = {name = "minecraft:potatoes", age = 7, seed = "minecraft:potato"},
- Wart = {name = "minecraft:nether_wart", age = 3, seed = "minecraft:nether_wart"}
- }
- local FarmLand = {
- ["one"] = {
- [1] = {
- [1] = Blocks.Dirt,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Dirt,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- },
- [2] = {
- [1] = Blocks.Dirt,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Dirt,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- },
- [3] = {
- [1] = Blocks.Dirt,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Dirt,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- },
- [4] = {
- [1] = Blocks.Dirt,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Dirt,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- },
- [5] = {
- [1] = Blocks.Dirt,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Water,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- },
- [6] = {
- [1] = Blocks.Dirt,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Dirt,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- },
- [7] = {
- [1] = Blocks.Dirt,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Dirt,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- },
- [8] = {
- [1] = Blocks.Dirt,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Dirt,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- },
- [9] = {
- [1] = Blocks.Dirt,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Dirt,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- },
- },
- ["two"] = {
- [1] = {
- [1] = Blocks.Water,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Dirt,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- [10] = Blocks.Water,
- },
- },
- ["three"] = {
- [1] = {
- [1] = Blocks.Dirt,
- [2] = Blocks.Dirt,
- [3] = Blocks.Dirt,
- [4] = Blocks.Dirt,
- [5] = Blocks.Water,
- [6] = Blocks.Dirt,
- [7] = Blocks.Dirt,
- [8] = Blocks.Dirt,
- [9] = Blocks.Dirt,
- },
- },
- }
- local Tool = {
- PickAxe = "minecraft:diamond_pickaxe",
- Shovel = "minecraft:diamond_shovel",
- Axe = "minecraft:diamond_axe",
- Hoe = "minecraft:diamond_hoe",
- Sword = "minecraft:diamond_sword"
- }
- local Color = {
- Green = colors.green,
- Red = colors.red,
- Black = colors.black,
- White = colors.white,
- Orange = colors.orange,
- Magenta = colors.magenta,
- LightBlue = colors.lightBlue,
- Yellow = colors.yellow,
- Lime = colors.lime,
- Pink = colors.pink,
- Gray = colors.gray,
- LightGray = colors.lightGray,
- Cyan = colors.cyan,
- Purple = colors.purple,
- Blue = colors.blue,
- Brown = colors.brown,
- }
- local Turtle = {
- System = { TurtleName = "T1 ",
- PowerOn = true,
- Free = true,
- GroupState = false,
- Nether = false, -- If tutrle is in the nether put to true
- First = true, -- For first time startup, after that its set to false
- Modem = { OwnID = 1,
- SharedID = 200,
- ServerID = 100,
- foundWireless = false,
- },
- },
- Data = {
- FuelLevel = 0,
- Cor = {
- X = 0,
- Y = 0,
- Z = 0,
- R = 1,
- },
- Home = {
- X = 0,
- Y = 0,
- Z = 0,
- R = 1,
- },
- Quarry = {
- X = 0,
- Y = 0,
- Z = 0,
- R = 1,
- Blocks = 0,
- Lines = 0,
- Layers = 0,
- },
- Height = {
- Max = 250,
- Min = 6,
- Travel = 250,
- },
- Farms = {
- Normale = {
- Overworld = {},
- Nether = {},
- },
- TreeFrams = {},
- },
- Slot = {},
- },
- Move = { Forward = turtle.forward,
- Back = turtle.back,
- Left = turtle.turnLeft,
- Right = turtle.turnRight,
- Up = turtle.up,
- Down = turtle.down,
- },
- Attack = { Forward = turtle.attack,
- Up = turtle.attackUp,
- Down = turtle.attackDown,
- },
- Dig = { Forward = turtle.dig,
- Up = turtle.digUp,
- Down = turtle.digDown,
- },
- Suck = { Forward = turtle.suck,
- Up = turtle.suckUp,
- Down = turtle.suckDown,
- },
- Drop = { Forward = turtle.drop,
- Up = turtle.dropUp,
- Down = turtle.dropDown,
- },
- Place = { Forward = turtle.place,
- Up = turtle.placeUp,
- Down = turtle.placeDown,
- },
- Detect = { Forward = turtle.detect,
- Up = turtle.detectUp,
- Down = turtle.detectDown,
- State = "Zero",
- },
- Inspect = { Forward = turtle.inspect,
- Up = turtle.inspectUp,
- Down = turtle.inspectDown,
- State = {Up = {name = "air"},
- Forward = {name = "air"},
- Down = {name = "air"},
- },
- },
- Compare = { Forward = turtle.compare,
- Up = turtle.compareUp,
- Down = turtle.compareDown,
- To = turtle.compareTo,
- State = "Zero",
- },
- Fuel = { Refuel = turtle.refuel,
- GetFuelLevel = turtle.getFuelLevel,
- GetFuelLimit = turtle.getFuelLimit,
- MinFuel = 5000,
- },
- Equip = { Left = turtle.equipLeft,
- Right = turtle.equipRight,
- },
- Slot = { Select = turtle.select,
- Selected = turtle.getSelectedSlot,
- Item = { Count = turtle.getItemCount,
- Space = turtle.getItemSpace,
- Detail = turtle.getItemDetail,
- },
- },
- TransferTo = turtle.transferTo,
- }
- local oldName
- local BlackListedDigging = {}
- local Side = "North"
- local zDiff = {-1, 0, 1, 0} -- Differents between north and south on z ax
- local xDiff = {0, 1, 0, -1} -- Differents between east and west om x ax
- local w, h = Screen.getSize()
- local NameLen = 15
- local nHeadOption = 1
- local nInfoOption = 1
- local nSystemOption = 1
- local nSlotSelectOption = 1
- local nEquipOption = 1
- local nDetectOption = 1
- local nInspectOption = 1
- local nCompareOption = 1
- local nMovementsOption = 1
- local nAttackOption = 1
- local nDigOption = 1
- local nSuckOption = 1
- local nDropOption = 1
- local nPlaceOption = 1
- local nProgramsOption = 1
- local nTreeFarmOption = 1
- local nFarmOption = 1
- local nWhatLandOption = 1
- local nMakeNormaleFarmLandsOption = 1
- local nFarmFarmingOption = 1
- local nPlowOption = 1
- local nNetherOption = 1
- local nPlantOption = 1
- local nHarvestOption = 1
- local MaxHeadOptions = 4
- local MaxInfoOptions = 2
- local MaxSystemOptions = 14
- local MaxSlotSelectOptions = 2
- local MaxEquipOptions = 2
- local MaxDetectOptions = 3
- local MaxInspectOptions = 3
- local MaxCompareOptions = 3
- local MaxMovementsOptions = 9
- local MaxAttackOptions = 3
- local MaxDigOptions = 3
- local MaxSuckOptions = 3
- local MaxDropOptions = 3
- local MaxPlaceOptions = 3
- local MaxProgramsOptions = 4
- local MaxTreeFarmOptions = 2
- local MaxFarmOptions = 2
- local MaxWhatLandOptions = 2
- local MaxMakeNormaleFarmLandsOptions = 3
- local MaxFarmFarmingOptions = 4
- local MaxPlantOptions = 5
- local MovementPage = 1
- local MaxMovementPage = math.ceil(MaxMovementsOptions/8)
- local Temp = {}
- -- System Stuff Fuctions
- function HadError(Mess)
- print(Mess)
- SetColors(Color.Black, Color.White)
- Screen.setCursorPos(1, h)
- error()
- end
- function SetColors(Background, Text)
- Screen.setBackgroundColor(Background)
- Screen.setTextColor(Text)
- end
- function GetPersNames()
- return Per.getNames()
- end
- function FindWirelessModem()
- for i,name in pairs(Pers) do
- for j,method in pairs(Per.getMethods(name)) do
- if (method == 'isWireless') then
- Modem = Per.wrap(name)
- if (Modem.isWireless()) then
- Turtle.System.Modem.foundWireless = true
- break
- else
- Modem = {}
- end
- end
- end
- if (Turtle.System.Modem.foundWireless) then
- break
- end
- end
- end
- function checkPers()
- Pers = GetPersNames()
- FindWirelessModem()
- if (Turtle.System.Modem.foundWireless) then
- Send = Modem.transmit
- local Ownid = Modem.isOpen(Turtle.System.Modem.OwnID)
- if not(Ownid) then
- Modem.open(Turtle.System.Modem.OwnID)
- end
- if Turtle.System.GroupState then
- local Sharedid = Modem.isOpen(Turtle.System.Modem.SharedID)
- if not(Sharedid) then
- Modem.open(Turtle.System.Modem.SharedID)
- end
- else
- local Sharedid = Modem.isOpen(Turtle.System.Modem.SharedID)
- if Sharedid then
- Modem.close(Turtle.System.Modem.SharedID)
- end
- end
- end
- end
- function SafeLog(DotA)
- local Map = fs.exists("/OS/Log/")
- if not(Map) then
- fs.makeDir("/OS/Log/")
- end
- local F1l3 = fs.exists("/OS/Log/Log.Log")
- if not(F1l3) then
- File = fs.open("/OS/Log/Log.Log", "w")
- for a, b in pairs(DotA) do
- local Test = tostring(a)..": "..tostring(b)
- File.writeLine(Test)
- end
- File.writeLine("---")
- File.close()
- else
- File = fs.open("/OS/Log/Log.Log", "a")
- for a, b in pairs(DotA) do
- local Test = tostring(a)..": "..tostring(b)
- File.writeLine(Test)
- end
- File.writeLine("---")
- File.close()
- end
- end
- function PrintLog()
- SendToServer("Printing Log", 0)
- sleep(1)
- local File = fs.exists("/OS/Log/Log.Log")
- if File then
- local Dataa = {What = "Command", Command = "/PR1NTL0GST4RT/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Dataa))
- local Event, Part1, Id, RId, Message = System.pullEvent("modem_message")
- File = fs.open("/OS/Log/Log.Log", "r")
- while Message == "R34DY" do
- local Line = File.readLine()
- if not(Line) or Line == nil then
- break
- end
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, tostring(Line))
- local Event, Part1, Id, RId, Message = System.pullEvent("modem_message")
- end
- File.close()
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, "/D0N3/")
- fs.delete("/OS/Log/Log.Log")
- SendToServer("Printing Done", 0)
- sleep(1)
- end
- end
- -- Script Check and Update from the Server
- function CheckVersion()
- Temp.OldVersion = {}
- Temp.OldVersion.A = tonumber(string.sub (Version, 1, 1))
- Temp.OldVersion.B = tonumber(string.sub (Version, 3, 3))
- Temp.OldVersion.C = tonumber(string.sub (Version, 5, 5))
- file = fs.exists("/OS/.Version.txt")
- if file then
- local NewTurtleVersion
- fs.delete("/OS/.Version.txt")
- shell.run("pastebin get NjmG2aH4 /OS/.Version.txt")
- file = fs.open("/OS/.Version.txt", "r")
- NewTurtleVersion = file.readLine()
- file.close()
- Temp.NewVersion = {}
- Temp.NewVersion.A = tonumber(string.sub(NewTurtleVersion, 1, 1))
- Temp.NewVersion.B = tonumber(string.sub(NewTurtleVersion, 3, 3))
- Temp.NewVersion.C = tonumber(string.sub(NewTurtleVersion, 5, 5))
- 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
- file = fs.exists("/OS/.Menu.lua")
- if file then
- fs.delete("/OS/.Menu.lua")
- end
- shell.run("pastebin get dsHg8DQh /OS/.Menu.lua")
- Screen.clear()
- Text = "Rebooting..."
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.write(Text)
- sleep(3)
- System.reboot()
- end
- else
- local NewTurtleVersion
- shell.run("pastebin get NjmG2aH4 /OS/.Version.txt")
- file = fs.open("/OS/.Version.txt", "r")
- NewTurtleVersion = file.readLine()
- file.close()
- Temp.NewVersion = {}
- Temp.NewVersion.A = tonumber(string.sub(NewTurtleVersion, 1, 1))
- Temp.NewVersion.B = tonumber(string.sub(NewTurtleVersion, 3, 3))
- Temp.NewVersion.C = tonumber(string.sub(NewTurtleVersion, 5, 5))
- 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
- file = fs.exists("/OS/.Menu.lua")
- if file then
- fs.delete("/OS/.Menu.lua")
- end
- shell.run("pastebin get dsHg8DQh /OS/.Menu.lua")
- Screen.clear()
- Text = "Rebooting..."
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.write(Text)
- sleep(3)
- System.reboot()
- end
- end
- end
- -- Fuel Funtions
- function GetFuel()
- return Turtle.Fuel.GetFuelLevel()
- end
- function ReFuel()
- local Inventory = Per.wrap("front")
- if Inventory then
- for Slot = 1, Inventory.size() do
- local Item = Inventory.getItemDetail(Slot)
- if Item then
- if string.find(Item.name, "coal") then
- Inventory.pushItems("back", Slot)
- TurnLeft()
- TurnLeft()
- Turtle.Suck.Forward()
- TurnRight()
- TurnRight()
- end
- end
- end
- for i = 1, 16, 1 do
- Turtle.Slot.Select(i)
- Turtle.Fuel.Refuel()
- end
- Turtle.Slot.Select(1)
- EmptyInventory()
- end
- end
- function CheckFuel()
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- ReFuel()
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- if Screen.isColor() then
- C1 = Color.Red
- C2 = Color.Black
- end
- SetColors(C1, C2)
- HadError("Fuel to low or cant refuel!")
- end
- end
- end
- function Fuel()
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- if Turtle.Data.Cor.X ~= Turtle.Data.Home.X or Turtle.Data.Cor.Y ~= Turtle.Data.Home.Y or Turtle.Data.Cor.Z ~= Turtle.Data.Home.Z then
- SendToServer("Low Fuel", 0)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y + 1, Turtle.Data.Quarry.Z - 1)
- SendToServer("Low Fuel", 0)
- GoHome()
- end
- SendToServer("Low Fuel", 0)
- EmptyInventory()
- SendToServer("Low Fuel", 0)
- ReFuel()
- Turtle.Data.FuelLevel = GetFuel()
- while Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel do
- Screen.clear()
- if Screen.isColor then
- C1 = Color.Red
- C2 = Color.Black
- end
- SetColors(C1, C2)
- printCentered(math.floor(h/2),"Cant Refuel Give Coal And Press Enter!")
- SetColors(Color.Black, Color.White)
- SendToServer("Low Fuel", 0)
- local Event, p1, p2 = System.pullEvent("key")
- ReFuel()
- Turtle.Data.FuelLevel = GetFuel()
- end
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Height.Travel, Turtle.Data.Quarry.Z)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y + 1, Turtle.Data.Quarry.Z)
- GoTo(SX, SY + 1, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- -- Inventory Funtion
- function EmptyInventory()
- for i = 1, 16, 1 do
- Turtle.Slot.Select(i)
- if Turtle.System.Nether then
- Turtle.Drop.Up()
- else
- Turtle.Drop.Down()
- end
- end
- Turtle.Slot.Select(1)
- end
- function CheckEmptyInventory()
- local InvFull = Turtle.Slot.Item.Count(16) > 0
- if InvFull then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- SendToServer("Inv. Full", 0)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y + 1, Turtle.Data.Quarry.Z - 1)
- SendToServer("GoTo", 0)
- GoHome()
- EmptyInventory()
- SendToServer("GoTo", 0)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Height.Travel, Turtle.Data.Quarry.Z)
- SendToServer("GoTo", 0)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y + 1, Turtle.Data.Quarry.Z)
- GoTo(SX, SY + 1, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- -- Gps Funtion
- function GPS()
- Turtle.Data.Cor.X, Turtle.Data.Cor.Y, Turtle.Data.Cor.Z = gps.locate(3)
- if Turtle.Data.Cor.X and Turtle.Data.Cor.Y and Turtle.Data.Cor.Z then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- if Turtle.System.Nether == false then
- Turtle.Move.Up()
- Turtle.Move.Forward()
- elseif Turtle.System.Nether == true then
- Turtle.Move.Down()
- Turtle.Move.Forward()
- end
- Turtle.Data.Cor.X, Turtle.Data.Cor.Y, Turtle.Data.Cor.Z = gps.locate(3)
- if Turtle.Data.Cor.X == SX and Turtle.Data.Cor.Z == SZ then
- HadError("Cant move or low fuel!")
- elseif Turtle.Data.Cor.X < SX then
- Turtle.Data.Cor.R = 4
- elseif Turtle.Data.Cor.X > SX then
- Turtle.Data.Cor.R = 2
- elseif Turtle.Data.Cor.Z < SZ then
- Turtle.Data.Cor.R = 1
- elseif Turtle.Data.Cor.Z > SZ then
- Turtle.Data.Cor.R = 3
- end
- if Turtle.System.Nether == false then
- Turtle.Move.Back()
- Turtle.Move.Down()
- elseif Turtle.System.Nether == true then
- Turtle.Move.Back()
- Turtle.Move.Up()
- end
- Turtle.Data.Cor.X, Turtle.Data.Cor.Y, Turtle.Data.Cor.Z = gps.locate(3)
- else
- Text = "No GPS found!"
- Screen.clear()
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- if (Screen.isColor) then
- C1 = Color.Red
- C2 = Color.Black
- end
- SetColors(C1, C2)
- HadError(Text)
- end
- end
- -- Startup And Data Saving and Data Loading And for first time Asking for Data Functions
- function LoadSettings()
- local Map = fs.exists("/OS/.Data")
- if not(Map) then
- fs.makeDir("/OS/.Data")
- end
- local File = fs.exists("/OS/.Data/.Settings.set")
- if not(File) and Turtle.System.First == true then
- Asking()
- elseif File then
- File = fs.open("/OS/.Data/.Settings.set", "r")
- local Data = UnPack(File.readAll())
- File.close()
- Turtle.System = Data.System
- Turtle.Data = Data.Data
- end
- end
- function SafeSettings()
- local Data = {System = Turtle.System, Data = Turtle.Data}
- local Map = fs.exists("/OS/.Data/")
- if not(Map) then
- fs.makeDir("/OS/.Data")
- end
- File = fs.open("/OS/.Data/.Settings.set", "w")
- File.write(Pack(Data))
- File.close()
- end
- function LoadBlackListedDigging()
- local Doto = {What = "Command", Command = "/LoadBlackListedDigging/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Doto))
- local Event, Part1, Id, RId, Message = System.pullEvent("modem_message")
- if Message ~= nil then
- BlackListedDigging = UnPack(Message)
- end
- end
- function SafeBlackListedDigging()
- local Doto = {What = "Command", Command = "/SaveBlackListedDigging/", Data = BlackListedDigging}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Doto))
- end
- function Asking()
- SetColors(Color.Black, Color.White)
- Screen.clear()
- Screen.setCursorPos(1, 1)
- print("Welcome :-D")
- print(" ")
- write("Turtle name: ")
- local name = read()
- Turtle.System.TurtleName = name.." "
- write("Turtle ID: ")
- Turtle.System.Modem.OwnID = tonumber(read())
- write("Turtle home cordinates X: ")
- Turtle.Data.Home.X = tonumber(read())
- write("Turtle home cordinates Y: ")
- Turtle.Data.Home.Y = tonumber(read())
- write("Turtle home cordinates Z: ")
- Turtle.Data.Home.Z = tonumber(read())
- print("Turtle Rotation. 1 = North, 2 = East, 3 = South, 4 is West: ")
- Turtle.Data.Home.R = tonumber(read())
- write("Server ID: ")
- Turtle.System.Modem.ServerID = tonumber(read())
- write("Chared channel ID: ")
- Turtle.System.Modem.SharedID = tonumber(read())
- write("TravelHeight: ")
- Turtle.Data.Height.Travel = tonumber(read())
- local GotKey = false
- while not(GotKey) do
- write("Is this Turtle in the nether? Y/N: ")
- local Event, Key, IsHeld = System.pullEvent("key")
- if Key == keys.y then
- Turtle.System.Nether = true
- GotKey = true
- elseif Key == keys.n then
- Turtle.System.Nether = false
- GotKey = true
- end
- end
- Turtle.System.First = false
- SafeSettings()
- end
- function Startup()
- SetColors(Color.Black, Color.White)
- Screen.clear()
- Screen.setCursorPos(1, 1)
- local Text = "Loading..."
- Screen.clear()
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) - 1)
- print(Text)
- System.pullEvent = System.pullEventRaw
- Pers = GetPersNames()
- Text = "Settings"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- LoadSettings()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- local Text = "Loading..."
- Screen.clear()
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) - 1)
- print(Text)
- Text = "Wireless Modem"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- local C1, C2 = Color.Black, Color.White
- if (Screen.isColor) then
- C1 = Color.Orange
- C2 = Color.Black
- end
- SetColors(C1, C2)
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- SetColors(Color.Black, Color.White)
- Turtle.System.Modem.foundWireless = false
- FindWirelessModem()
- if (Turtle.System.Modem.foundWireless) then
- Text = "Found Wireless Modem"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- if (Screen.isColor) then
- C1 = Color.Green
- C2 = Color.Black
- end
- SetColors(C1, C2)
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- SetColors(Color.Black, Color.White)
- Send = Modem.transmit -- Makes a new command for Modem.transmit to send stuff
- Modem.closeAll()
- Modem.open(Turtle.System.Modem.OwnID)
- elseif not(Turtle.System.Modem.foundWireless) then
- Text = "No Wireless Modem Found !"
- Screen.clear()
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- if (Screen.isColor) then
- C1 = Color.Red
- C2 = Color.Black
- end
- SetColors(C1, C2)
- HadError(Text)
- end
- Text = "Computer/Turtle Name"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- System.setComputerLabel(Turtle.System.TurtleName)
- Text = "Checking Shared Channel ID"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- if Turtle.System.GroupState then
- Text = "Opening Shared Channel ID"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- Modem.open(Turtle.System.Modem.SharedID)
- sleep(math.random(0.5, 2.0))
- end
- Text = "Server CheckIn"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- local Data = {Name = Turtle.System.TurtleName, Cor = Turtle.Data.Cor, FuelLevel = Turtle.Data.FuelLevel, Doing = "Home", GroupState = Turtle.System.GroupState, Inspect = Turtle.Inspect.State, Compare = Turtle.Compare.State, Detect = Turtle.Detect.State}
- local DATA = {What = "Command", Command = "/CH3CK1N/", Dita = Data}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(DATA))
- sleep(math.random(0.5, 2.0))
- Text = "Asking Server Settings"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- LoadBlackListedDigging()
- LoadLand()
- LoadTreeFarm()
- Text = "Checking Version"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- CheckVersion()
- Text = "Fuel"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- CheckFuel()
- Text = "GPS"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- GPS()
- Text = "Checking If Home"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- if Turtle.Data.Cor.X ~= Turtle.Data.Home.X or Turtle.Data.Cor.Y ~= Turtle.Data.Home.Y or Turtle.Data.Cor.Z ~= Turtle.Data.Home.Z then
- Text = "Going Home"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- GoHome()
- end
- Text = "Checking Rotation"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- sleep(math.random(0.5, 2.0))
- if Turtle.Data.Cor.R ~= Turtle.Data.Home.R then
- Text = "Rotating"
- Screen.setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Screen.clearLine()
- Screen.write(Text)
- TurnDirection(Turtle.Data.Home.R)
- end
- end
- -- Function for Make string one length and Print Centered or print begin screen Quarted1 (clearLine) or print on end of screen Quarted2 (no clearLine) or print on end of screen Quarted3 (clearLine)
- function PadString(sText, iLen)
- local iTextLen = string.len(sText)
- -- Too short, pad
- if (iTextLen < iLen) then
- local iDiff = iLen - iTextLen
- return(sText..string.rep(" ",iDiff))
- end
- -- Too long, trim
- if (iTextLen > iLen) then
- return(string.sub(sText,1,iLen))
- end
- -- Exact length
- return(sText)
- end
- function printCentered(y,s)
- local x = math.floor((w - string.len(s)) /2)
- Screen.setCursorPos(x,y)
- Screen.clearLine()
- Screen.write(s)
- end
- function printQuarted1(y,s)
- Screen.setCursorPos(1,y)
- Screen.clearLine()
- Screen.write(s)
- end
- function printQuarted2(y,s)
- local x = math.floor(w - string.len(s))
- Screen.setCursorPos(x,y)
- Screen.write(s)
- end
- function printQuarted3(y,s)
- local x = math.floor(w - string.len(s))
- Screen.setCursorPos(x,y)
- Screen.clearLine()
- Screen.write(s)
- end
- -- Menu Funtions
- -- Head Menu
- function drawHeadMenu()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Screen.setCursorPos(w-NameLen, 1)
- if nHeadOption == 1 then
- Screen.write("Info")
- elseif nHeadOption == 2 then
- Screen.write("System")
- elseif nHeadOption == 3 then
- Screen.write("Movements")
- elseif nHeadOption == 4 then
- Screen.write("Program's")
- elseif nHeadOption == 5 then
- Screen.write("")
- elseif nHeadOption == 6 then
- Screen.write("")
- elseif nHeadOption == 7 then
- Screen.write("")
- elseif nHeadOption == 8 then
- Screen.write("")
- elseif nHeadOption == 9 then
- Screen.write("")
- elseif nHeadOption == 10 then
- Screen.write("")
- elseif nHeadOption == 11 then
- Screen.write("")
- elseif nHeadOption == 12 then
- Screen.write("")
- elseif nHeadOption == 13 then
- Screen.write("")
- elseif nHeadOption == 14 then
- Screen.write("")
- elseif nHeadOption == 15 then
- Screen.write("")
- elseif nHeadOption == 16 then
- Screen.write("")
- else
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'Q' to quit.")
- SetColors(Color.Black, Color.White)
- end
- function drawHeadFrontend()
- printCentered(math.floor(h/2) -3, PadString(" Head Menu",NameLen))
- printQuarted1(math.floor(h/2) -1, ((nHeadOption == 1) and string.format("%s%s",PadString("[ Info",NameLen-1),"]") or PadString(" Info",NameLen)))
- printQuarted1(math.floor(h/2) +0, ((nHeadOption == 2) and string.format("%s%s",PadString("[ System",NameLen-1),"]") or PadString(" System",NameLen)))
- printQuarted1(math.floor(h/2) +1, ((nHeadOption == 3) and string.format("%s%s",PadString("[ Movements",NameLen-1),"]") or PadString(" Movements",NameLen)))
- printQuarted1(math.floor(h/2) +2, ((nHeadOption == 4) and string.format("%s%s",PadString("[ Program's",NameLen-1),"]") or PadString(" Program's",NameLen)))
- printQuarted1(math.floor(h/2) +3, ((nHeadOption == 5) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted1(math.floor(h/2) +4, ((nHeadOption == 6) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted1(math.floor(h/2) +5, ((nHeadOption == 7) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted1(math.floor(h/2) +6, ((nHeadOption == 8) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted2(math.floor(h/2) -1, ((nHeadOption == 9) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted2(math.floor(h/2) +0, ((nHeadOption == 10) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted2(math.floor(h/2) +1, ((nHeadOption == 11) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted2(math.floor(h/2) +2, ((nHeadOption == 12) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted2(math.floor(h/2) +3, ((nHeadOption == 13) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted2(math.floor(h/2) +4, ((nHeadOption == 14) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted2(math.floor(h/2) +5, ((nHeadOption == 15) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted2(math.floor(h/2) +6, ((nHeadOption == 16) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- end
- -- Info Menu
- function drawInfoMenu()
- if nInfoOption == 1 then
- Screen.clear()
- Screen.setCursorPos(w-NameLen, 1)
- Screen.write("Info Menu Page "..nInfoOption)
- Screen.setCursorPos(1, 1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Screen.setCursorPos(1, 2)
- Turtle.Data.FuelLevel = GetFuel()
- Screen.write("Fuel: "..Turtle.Data.FuelLevel)
- Screen.setCursorPos(1, 3)
- Screen.write("Cor.| X: "..Turtle.Data.Cor.X.." Y: "..Turtle.Data.Cor.Y.." Z: "..Turtle.Data.Cor.Z)
- Screen.setCursorPos(1, 4)
- Side = GetOrientNames(Turtle.Data.Cor.R)
- Screen.write("Looking To: "..Side)
- Screen.setCursorPos(1, 5)
- Side = GetOrientNames(Turtle.Data.Quarry.R)
- Screen.write("GoTo| X: "..Turtle.Data.Quarry.X.." Y: "..Turtle.Data.Quarry.Y.." Z: "..Turtle.Data.Quarry.Z.." R: "..Side)
- Screen.setCursorPos(1, 6)
- Screen.write("GroupState: "..tostring(Turtle.System.GroupState))
- Screen.setCursorPos(1, 7)
- Screen.write("Nether:"..tostring(Turtle.System.Nether))
- Screen.setCursorPos(1, 8)
- Screen.write("Modem| Own ID: "..Turtle.System.Modem.OwnID)
- Screen.setCursorPos(1, 9)
- Screen.write("Modem| Server ID: "..Turtle.System.Modem.ServerID)
- Screen.setCursorPos(1, 10)
- Screen.write("Modem| Shared ID: "..Turtle.System.Modem.SharedID)
- Screen.setCursorPos(1, 11)
- Screen.write(" ")
- Screen.setCursorPos(1, 12)
- Screen.write(" ")
- elseif nInfoOption == 2 then
- Screen.clear()
- Screen.setCursorPos(w-NameLen, 1)
- Screen.write("Info Menu Page "..nInfoOption)
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- -- System Menu
- function drawSystemMenu()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Screen.setCursorPos(1, 2)
- Screen.write("Compare: "..Turtle.Compare.State)
- Screen.setCursorPos(w-NameLen, 2)
- Screen.write("Detect: "..Turtle.Detect.State)
- Screen.setCursorPos(w-NameLen, 1)
- if nSystemOption == 1 then
- Screen.write("GroupState")
- elseif nSystemOption == 2 then
- Screen.write("Refuel")
- elseif nSystemOption == 3 then
- Screen.write("Select Slot")
- elseif nSystemOption == 4 then
- Screen.write("Equip")
- elseif nSystemOption == 5 then
- Screen.write("Transfer To")
- elseif nSystemOption == 6 then
- Screen.write("Craft")
- elseif nSystemOption == 7 then
- Screen.write("Detect")
- elseif nSystemOption == 8 then
- Screen.write("Inspect")
- elseif nSystemOption == 9 then
- Screen.write("Compare")
- elseif nSystemOption == 10 then
- Screen.write("Print Log")
- elseif nSystemOption == 11 then
- Screen.write("Reboot")
- elseif nSystemOption == 12 then
- Screen.write("Reset Turtle")
- elseif nSystemOption == 13 then
- Screen.write("BlackListedDigging")
- elseif nSystemOption == 14 then
- Screen.write("Uninstall")
- elseif nSystemOption == 15 then
- Screen.write("")
- elseif nSystemOption == 16 then
- Screen.write("")
- else
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawSystemFrontend()
- printCentered(math.floor(h/2) -3, PadString(" System Menu",NameLen))
- printQuarted1(math.floor(h/2) -1, ((nSystemOption == 1) and string.format("%s%s",PadString("[ GroupState",NameLen-1),"]") or PadString(" GroupState",NameLen)))
- printQuarted1(math.floor(h/2) +0, ((nSystemOption == 2) and string.format("%s%s",PadString("[ Refuel",NameLen-1),"]") or PadString(" Refuel",NameLen)))
- printQuarted1(math.floor(h/2) +1, ((nSystemOption == 3) and string.format("%s%s",PadString("[ Select Slot",NameLen-1),"]") or PadString(" Select Slot",NameLen)))
- printQuarted1(math.floor(h/2) +2, ((nSystemOption == 4) and string.format("%s%s",PadString("[ Equip",NameLen-1),"]") or PadString(" Equip",NameLen)))
- printQuarted1(math.floor(h/2) +3, ((nSystemOption == 5) and string.format("%s%s",PadString("[ Transfer To",NameLen-1),"]") or PadString(" Transfer To",NameLen)))
- printQuarted1(math.floor(h/2) +4, ((nSystemOption == 6) and string.format("%s%s",PadString("[ Craft",NameLen-1),"]") or PadString(" Craft",NameLen)))
- printQuarted1(math.floor(h/2) +5, ((nSystemOption == 7) and string.format("%s%s",PadString("[ Detect",NameLen-1),"]") or PadString(" Detect",NameLen)))
- printQuarted1(math.floor(h/2) +6, ((nSystemOption == 8) and string.format("%s%s",PadString("[ Inspect",NameLen-1),"]") or PadString(" Inspect",NameLen)))
- printQuarted2(math.floor(h/2) -1, ((nSystemOption == 9) and string.format("%s%s",PadString("[ Compare",NameLen-1),"]") or PadString(" Compare",NameLen)))
- printQuarted2(math.floor(h/2) +0, ((nSystemOption == 10) and string.format("%s%s",PadString("[ Print Log",NameLen-1),"]") or PadString(" Print Log",NameLen)))
- printQuarted2(math.floor(h/2) +1, ((nSystemOption == 11) and string.format("%s%s",PadString("[ Reboot",NameLen-1),"]") or PadString(" Reboot",NameLen)))
- printQuarted2(math.floor(h/2) +2, ((nSystemOption == 12) and string.format("%s%s",PadString("[ Reset Turtle",NameLen-1),"]") or PadString(" Reset Turtle",NameLen)))
- printQuarted2(math.floor(h/2) +3, ((nSystemOption == 13) and string.format("%s%s",PadString("[ Add BLD",NameLen-1),"]") or PadString(" Add BLD",NameLen)))
- printQuarted2(math.floor(h/2) +4, ((nSystemOption == 14) and string.format("%s%s",PadString("[ Uninstall",NameLen-1),"]") or PadString(" Uninstall",NameLen)))
- printQuarted2(math.floor(h/2) +5, ((nSystemOption == 15) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted2(math.floor(h/2) +6, ((nSystemOption == 16) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- end
- -- Sub Menu's In System
- function drawSlotSelectFrontend()
- printQuarted1(math.floor(h/2) +0, PadString(" ",NameLen))
- printQuarted1(math.floor(h/2) +1, ((nSlotSelectOption == 1) and string.format("%s%s",PadString("[ Add",NameLen-1),"]") or PadString(" Add",NameLen)))
- printQuarted1(math.floor(h/2) +2, ((nSlotSelectOption == 2) and string.format("%s%s",PadString("[ Subtract",NameLen-1),"]") or PadString(" Subtract",NameLen)))
- printQuarted1(math.floor(h/2) +3, PadString(" ",NameLen))
- end
- function drawEquipFrontend()
- printQuarted1(math.floor(h/2) +1, PadString(" ",NameLen))
- printQuarted1(math.floor(h/2) +2, ((nEquipOption == 1) and string.format("%s%s",PadString("[ Left",NameLen-1),"]") or PadString(" Left",NameLen)))
- printQuarted1(math.floor(h/2) +3, ((nEquipOption == 2) and string.format("%s%s",PadString("[ Right",NameLen-1),"]") or PadString(" Right",NameLen)))
- printQuarted1(math.floor(h/2) +4, PadString(" ",NameLen))
- end
- function drawDetectFrontend()
- printQuarted1(math.floor(h/2) +2, PadString(" ",NameLen))
- printQuarted1(math.floor(h/2) +3, ((nDetectOption == 1) and string.format("%s%s",PadString("[ Forward",NameLen-1),"]") or PadString(" Forward",NameLen)))
- printQuarted1(math.floor(h/2) +4, ((nDetectOption == 2) and string.format("%s%s",PadString("[ Up",NameLen-1),"]") or PadString(" Up",NameLen)))
- printQuarted1(math.floor(h/2) +5, ((nDetectOption == 3) and string.format("%s%s",PadString("[ Down",NameLen-1),"]") or PadString(" Down",NameLen)))
- printQuarted1(math.floor(h/2) +6, PadString(" ",NameLen))
- end
- function drawInspectFrontend()
- printQuarted1(math.floor(h/2) +2, PadString(" ",NameLen))
- printQuarted1(math.floor(h/2) +3, ((nInspectOption == 1) and string.format("%s%s",PadString("[ Forward",NameLen-1),"]") or PadString(" Forward",NameLen)))
- printQuarted1(math.floor(h/2) +4, ((nInspectOption == 2) and string.format("%s%s",PadString("[ Up",NameLen-1),"]") or PadString(" Up",NameLen)))
- printQuarted1(math.floor(h/2) +5, ((nInspectOption == 3) and string.format("%s%s",PadString("[ Down",NameLen-1),"]") or PadString(" Down",NameLen)))
- printQuarted1(math.floor(h/2) +6, PadString(" ",NameLen))
- end
- function drawCompareFrontend()
- printQuarted3(math.floor(h/2) -3, PadString(" ",NameLen))
- printQuarted3(math.floor(h/2) -2, ((nCompareOption == 1) and string.format("%s%s",PadString("[ Forward",NameLen-1),"]") or PadString(" Forward",NameLen)))
- printQuarted3(math.floor(h/2) -1, ((nCompareOption == 2) and string.format("%s%s",PadString("[ Up",NameLen-1),"]") or PadString(" Up",NameLen)))
- printQuarted3(math.floor(h/2) +0, ((nCompareOption == 3) and string.format("%s%s",PadString("[ Down",NameLen-1),"]") or PadString(" Down",NameLen)))
- printQuarted3(math.floor(h/2) +1, PadString(" ",NameLen))
- end
- -- Info Page From Inspect
- function drawInspectInfoFrontend(Succes, DAta)
- Turtle.Data.FuelLevel = GetFuel()
- Screen.clear()
- if Succes then
- local a = 1
- local HeightA = 19
- printCentered(a, "Inspect")
- a = a + 2
- for Mame, Deta in pairs(DAta) do
- if a == HeightA then break end
- if type(Deta) == "table" then
- if a == HeightA then break end
- for MName, DEata in pairs(Deta) do
- if a == HeightA then break end
- if type(DEata) == "table" then
- if a == HeightA then break end
- for MMname, DeAta in pairs(DEata) do
- if a == HeightA then break end
- if type(DeAta) == "table" then
- if a == HeightA then break end
- for MMnameA, DeAtaA in pairs(DeAta) do
- if a == HeightA then break end
- if type(DeAtaA) == "table" then
- if a == HeightA then break end
- for MMnameB, DeAtaB in pairs(DeAtaA) do
- if a == HeightA then break end
- if type(DeAtaB) == "table" then
- if a == HeightA then break end
- for MMnameC, DeAtaC in pairs(DeAtaB) do
- if a == HeightA then break end
- if type(DeAtaC) ~= "table" then
- if a == HeightA then break end
- if MMnameC ~= nil and DeAtaC ~= nil then
- printCentered(a, PadString(Mame.."| "..MName.."| "..MMname.."| "..MMnameA.."| "..MMnameB.."| "..MMnameC.."| "..tostring(DeAtaC), w-4))
- a = a + 1
- if a == HeightA then break end
- end
- else
- if a == HeightA then break end
- printCentered(a, PadString(Mame.."| "..MName.."| "..MMname.."| "..MMnameA.."| "..MMnameB.."| "..MMnameC.."| Table Cant Read", w-4))
- a = a + 1
- if a == HeightA then break end
- end
- end
- else
- if a == HeightA then break end
- if MMnameB ~= nil and DeAtaB ~= nil then
- printCentered(a, PadString(Mame.."| "..MName.."| "..MMname.."| "..MMnameA.."| "..MMnameB.."| "..tostring(DeAtaB), w-4))
- a = a + 1
- if a == HeightA then break end
- end
- end
- end
- else
- if a == HeightA then break end
- if MMnameA ~= nil and DeAtaA ~= nil then
- printCentered(a, PadString(Mame.."| "..MName.."| "..MMname.."| "..MMnameA.."| "..tostring(DeAtaA), w-4))
- a = a + 1
- if a == HeightA then break end
- end
- end
- end
- else
- if a == HeightA then break end
- if MMname ~= nil and DeAta ~= nil then
- printCentered(a, PadString(Mame.."| "..MName.."| "..MMname.."| "..tostring(DeAta), w-4))
- a = a + 1
- if a == HeightA then break end
- end
- end
- end
- else
- if a == HeightA then break end
- if MName ~= nil and DEata ~= nil then
- printCentered(a, PadString(Mame.."| "..MName.."| "..tostring(DEata), w-4))
- a = a + 1
- if a == HeightA then break end
- end
- end
- end
- else
- if a == HeightA then break end
- if Mame ~= nil and Deta ~= nil then
- printCentered(a, PadString(Mame.."| "..tostring(Deta), w-4))
- a = a + 1
- if a == HeightA then break end
- end
- end
- end
- a = a + 1
- printCentered(a, " ")
- else
- printCentered(math.floor(h/2)-1, " ")
- printCentered(math.floor(h/2)+0, "No Block Found!")
- printCentered(math.floor(h/2)+1, " ")
- end
- end
- -- Movements Menu
- function drawMovementsMenu()
- Screen.clear()
- Screen.setCursorPos(1,1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Inspect("up")
- Inspect("forward")
- Inspect("down")
- printQuarted2(1, "Up: "..Turtle.Inspect.State.Up.name)
- printQuarted3(2, "Forward: "..Turtle.Inspect.State.Forward.name)
- printQuarted3(3, "Down: "..Turtle.Inspect.State.Down.name)
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawMovementsFrontend()
- if MovementPage == 1 then
- printQuarted3(math.floor(h/2) -1, ((nMovementsOption == 1) and string.format("%s%s",PadString("[ Attack",NameLen-1),"]") or PadString(" Attack",NameLen)))
- printQuarted3(math.floor(h/2) +0, ((nMovementsOption == 2) and string.format("%s%s",PadString("[ Dig",NameLen-1),"]") or PadString(" Dig",NameLen)))
- printQuarted3(math.floor(h/2) +1, ((nMovementsOption == 3) and string.format("%s%s",PadString("[ Suck",NameLen-1),"]") or PadString(" Suck",NameLen)))
- printQuarted3(math.floor(h/2) +2, ((nMovementsOption == 4) and string.format("%s%s",PadString("[ Drop",NameLen-1),"]") or PadString(" Drop",NameLen)))
- printQuarted3(math.floor(h/2) +3, ((nMovementsOption == 5) and string.format("%s%s",PadString("[ Place",NameLen-1),"]") or PadString(" Place",NameLen)))
- printQuarted3(math.floor(h/2) +4, ((nMovementsOption == 6) and string.format("%s%s",PadString("[ Go To",NameLen-1),"]") or PadString(" Go To",NameLen)))
- printQuarted3(math.floor(h/2) +5, ((nMovementsOption == 7) and string.format("%s%s",PadString("[ Go Home",NameLen-1),"]") or PadString(" Go Home",NameLen)))
- printQuarted3(math.floor(h/2) +6, ((nMovementsOption == 8) and string.format("%s%s",PadString("[ Turn Direction",NameLen-1),"]") or PadString(" Turn Direction",NameLen)))
- elseif MovementPage == 2 then
- printQuarted3(math.floor(h/2) -1, ((nMovementsOption == 9) and string.format("%s%s",PadString("[ Empty Inventory",NameLen-1),"]") or PadString(" Empty Inventory",NameLen)))
- printQuarted3(math.floor(h/2) +0, ((nMovementsOption == 10) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted3(math.floor(h/2) +1, ((nMovementsOption == 11) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted3(math.floor(h/2) +2, ((nMovementsOption == 12) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted3(math.floor(h/2) +3, ((nMovementsOption == 13) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted3(math.floor(h/2) +4, ((nMovementsOption == 14) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted3(math.floor(h/2) +5, ((nMovementsOption == 15) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- printQuarted3(math.floor(h/2) +6, ((nMovementsOption == 16) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- end
- Button.screen()
- end
- -- Sub Menu's in Movements
- function drawAttackFrontend()
- printQuarted3(math.floor(h/2) -3, PadString(" ",NameLen))
- printQuarted3(math.floor(h/2) -2, ((nAttackOption == 1) and string.format("%s%s",PadString("[ Forward",NameLen-1),"]") or PadString(" Forward",NameLen)))
- printQuarted3(math.floor(h/2) -1, ((nAttackOption == 2) and string.format("%s%s",PadString("[ Up",NameLen-1),"]") or PadString(" Up",NameLen)))
- printQuarted3(math.floor(h/2) +0, ((nAttackOption == 3) and string.format("%s%s",PadString("[ Down",NameLen-1),"]") or PadString(" Down",NameLen)))
- printQuarted3(math.floor(h/2) +1, PadString(" ",NameLen))
- Button.screen()
- end
- function drawDigFrontend()
- printQuarted3(math.floor(h/2) -2, PadString(" ",NameLen))
- printQuarted3(math.floor(h/2) -1, ((nDigOption == 1) and string.format("%s%s",PadString("[ Forward",NameLen-1),"]") or PadString(" Forward",NameLen)))
- printQuarted3(math.floor(h/2) +0, ((nDigOption == 2) and string.format("%s%s",PadString("[ Up",NameLen-1),"]") or PadString(" Up",NameLen)))
- printQuarted3(math.floor(h/2) +1, ((nDigOption == 3) and string.format("%s%s",PadString("[ Down",NameLen-1),"]") or PadString(" Down",NameLen)))
- printQuarted3(math.floor(h/2) +2, PadString(" ",NameLen))
- Button.screen()
- end
- function drawSuckFrontend()
- printQuarted3(math.floor(h/2) -1, PadString(" ",NameLen))
- printQuarted3(math.floor(h/2) +0, ((nSuckOption == 1) and string.format("%s%s",PadString("[ Forward",NameLen-1),"]") or PadString(" Forward",NameLen)))
- printQuarted3(math.floor(h/2) +1, ((nSuckOption == 2) and string.format("%s%s",PadString("[ Up",NameLen-1),"]") or PadString(" Up",NameLen)))
- printQuarted3(math.floor(h/2) +2, ((nSuckOption == 3) and string.format("%s%s",PadString("[ Down",NameLen-1),"]") or PadString(" Down",NameLen)))
- printQuarted3(math.floor(h/2) +3, PadString(" ",NameLen))
- Button.screen()
- end
- function drawDropFrontend()
- printQuarted3(math.floor(h/2) +0, PadString(" ",NameLen))
- printQuarted3(math.floor(h/2) +1, ((nDropOption == 1) and string.format("%s%s",PadString("[ Forward",NameLen-1),"]") or PadString(" Forward",NameLen)))
- printQuarted3(math.floor(h/2) +2, ((nDropOption == 2) and string.format("%s%s",PadString("[ Up",NameLen-1),"]") or PadString(" Up",NameLen)))
- printQuarted3(math.floor(h/2) +3, ((nDropOption == 3) and string.format("%s%s",PadString("[ Down",NameLen-1),"]") or PadString(" Down",NameLen)))
- printQuarted3(math.floor(h/2) +4, PadString(" ",NameLen))
- Button.screen()
- end
- function drawPlaceFrontend()
- printQuarted3(math.floor(h/2) +1, PadString(" ",NameLen))
- printQuarted3(math.floor(h/2) +2, ((nPlaceOption == 1) and string.format("%s%s",PadString("[ Forward",NameLen-1),"]") or PadString(" Forward",NameLen)))
- printQuarted3(math.floor(h/2) +3, ((nPlaceOption == 2) and string.format("%s%s",PadString("[ Up",NameLen-1),"]") or PadString(" Up",NameLen)))
- printQuarted3(math.floor(h/2) +4, ((nPlaceOption == 3) and string.format("%s%s",PadString("[ Down",NameLen-1),"]") or PadString(" Down",NameLen)))
- printQuarted3(math.floor(h/2) +5, PadString(" ",NameLen))
- Button.screen()
- end
- -- Program's Menu
- function drawProgramsMenu()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Screen.setCursorPos(w-NameLen, 1)
- if nProgramsOption == 1 then
- Screen.write("Quarry")
- elseif nProgramsOption == 2 then
- Screen.write("Tunnel 3X3")
- elseif nProgramsOption == 3 then
- Screen.write("Tree Farm")
- elseif nProgramsOption == 4 then
- Screen.write("Farm")
- -- elseif nProgramsOption == 5 then
- -- Screen.write("3D Paint Pro")
- else
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawProgramsFrontend()
- printCentered(math.floor(h/2) -3, PadString(" Program's Menu",NameLen))
- printQuarted1(math.floor(h/2) -1, ((nProgramsOption == 1) and string.format("%s%s",PadString("[ Quarry",NameLen-1),"]") or PadString(" Quarry",NameLen)))
- printQuarted1(math.floor(h/2) +0, ((nProgramsOption == 2) and string.format("%s%s",PadString("[ Tunnel 3X3",NameLen-1),"]") or PadString(" Tunnel 3X3",NameLen)))
- printQuarted1(math.floor(h/2) +1, ((nProgramsOption == 3) and string.format("%s%s",PadString("[ Tree Farm",NameLen-1),"]") or PadString(" Tree Farm",NameLen)))
- printQuarted1(math.floor(h/2) +2, ((nProgramsOption == 4) and string.format("%s%s",PadString("[ Farm",NameLen-1),"]") or PadString(" Farm",NameLen)))
- -- printQuarted1(math.floor(h/2) +3, ((nProgramsOption == 5) and string.format("%s%s",PadString("[ 3D Paint Pro",NameLen-1),"]") or PadString(" 3D Paint Pro",NameLen)))
- -- printQuarted1(math.floor(h/2) +4, ((nProgramsOption == 6) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- -- printQuarted1(math.floor(h/2) +5, ((nProgramsOption == 7) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- -- printQuarted1(math.floor(h/2) +6, ((nProgramsOption == 8) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- -- printQuarted2(math.floor(h/2) -1, ((nProgramsOption == 9) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- -- printQuarted2(math.floor(h/2) +0, ((nProgramsOption == 10) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- -- printQuarted2(math.floor(h/2) +1, ((nProgramsOption == 11) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- -- printQuarted2(math.floor(h/2) +2, ((nProgramsOption == 12) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- -- printQuarted2(math.floor(h/2) +3, ((nProgramsOption == 13) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- -- printQuarted2(math.floor(h/2) +4, ((nProgramsOption == 14) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- -- printQuarted2(math.floor(h/2) +5, ((nProgramsOption == 15) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- -- printQuarted2(math.floor(h/2) +6, ((nProgramsOption == 16) and string.format("%s%s",PadString("[ ",NameLen-1),"]") or PadString(" ",NameLen)))
- end
- -- TreeFram Menu
- function drawTreeFarmMenu()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Screen.setCursorPos(w-NameLen, 1)
- if nTreeFarmOption == 1 then
- Screen.write("Give In Cor.")
- elseif nTreeFarmOption == 2 then
- Screen.write("Farm At Cor.")
- else
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawTreeFarmFrontend()
- printCentered(math.floor(h/2) -3, PadString(" TreeFarm Menu",NameLen))
- printCentered(math.floor(h/2) -1, ((nTreeFarmOption == 1) and string.format("%s%s",PadString("[ Make",NameLen-1),"]") or PadString(" Make",NameLen)))
- printCentered(math.floor(h/2) +0, ((nTreeFarmOption == 2) and string.format("%s%s",PadString("[ Farm",NameLen-1),"]") or PadString(" Farm",NameLen)))
- end
- -- Farm Head Menu
- function drawFarmMenu()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Screen.setCursorPos(w-NameLen, 1)
- if nFarmOption == 1 then
- Screen.write("Make Farm")
- elseif nFarmOption == 2 then
- Screen.write("Farm")
- else
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawFarmFrontend()
- printCentered(math.floor(h/2) -3, PadString(" Farm Menu",NameLen))
- printCentered(math.floor(h/2) -1, ((nFarmOption == 1) and string.format("%s%s",PadString("[ Make",NameLen-1),"]") or PadString(" Make",NameLen)))
- printCentered(math.floor(h/2) +0, ((nFarmOption == 2) and string.format("%s%s",PadString("[ Farm",NameLen-1),"]") or PadString(" Farm",NameLen)))
- end
- -- Sub Menu's in Farm
- function drawWhatLandMenu()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Screen.setCursorPos(w-NameLen, 1)
- if nWhatLandOption == 1 then
- Screen.write("Normale Farm")
- elseif nWhatLandOption == 2 then
- Screen.write("Nether/Wart Farm")
- else
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawWhatLandFrontend()
- printCentered(math.floor(h/2) -3, PadString(" Make Farm Land Menu",NameLen))
- printCentered(math.floor(h/2) -1, ((nWhatLandOption == 1) and string.format("%s%s",PadString("[ Normale Farm",NameLen-1),"]") or PadString(" Normale Farm",NameLen)))
- printCentered(math.floor(h/2) +0, ((nWhatLandOption == 2) and string.format("%s%s",PadString("[ Nether/Wart Farm",NameLen-1),"]") or PadString(" Nether/Wart Farm",NameLen)))
- end
- function drawMakeNormaleFarmLandsMenu()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Screen.setCursorPos(w-NameLen, 1)
- if nMakeNormaleFarmLandsOption == 1 then
- Screen.write("Farm 1")
- elseif nMakeNormaleFarmLandsOption == 2 then
- Screen.write("Farm 2")
- elseif nMakeNormaleFarmLandsOption == 3 then
- Screen.write("Farm 3")
- else
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawMakeNormaleFarmLandsFrontend()
- if nMakeNormaleFarmLandsOption == 1 then
- printCentered(math.floor(h/2) -4, PadString("Choose Farm",NameLen))
- printCentered(math.floor(h/2) -2, PadString("DDDDDDDDD",NameLen))
- printCentered(math.floor(h/2) -1, PadString("DDDDDDDDD",NameLen))
- printCentered(math.floor(h/2) +0, PadString("DDDDDDDDD",NameLen))
- printCentered(math.floor(h/2) +1, PadString("DDDDDDDDD",NameLen))
- printCentered(math.floor(h/2) +2, PadString("DDDDWDDDD",NameLen))
- printCentered(math.floor(h/2) +3, PadString("DDDDDDDDD",NameLen))
- printCentered(math.floor(h/2) +4, PadString("DDDDDDDDD",NameLen))
- printCentered(math.floor(h/2) +5, PadString("DDDDDDDDD",NameLen))
- printCentered(math.floor(h/2) +6, PadString("DDDDDDDDD",NameLen))
- Screen.setCursorPos(1, math.floor(h/2) +0)
- Screen.write("9 By 9")
- Screen.setCursorPos(1, math.floor(h/2) +3)
- Screen.write("D = Dirt")
- Screen.setCursorPos(1, math.floor(h/2) +4)
- Screen.write("W = Water")
- elseif nMakeNormaleFarmLandsOption == 2 then
- printCentered(math.floor(h/2) -4, PadString("Choose Farm",NameLen))
- printCentered(math.floor(h/2) -2, PadString(" ",NameLen))
- printCentered(math.floor(h/2) -1, PadString("WDDDDDDDDW",NameLen))
- printCentered(math.floor(h/2) +0, PadString("WDDDDDDDDW",NameLen))
- printCentered(math.floor(h/2) +1, PadString("WDDDDDDDDW",NameLen))
- printCentered(math.floor(h/2) +2, PadString("..........",NameLen))
- printCentered(math.floor(h/2) +3, PadString(" ",NameLen))
- printCentered(math.floor(h/2) +4, PadString(" ",NameLen))
- printCentered(math.floor(h/2) +5, PadString(" ",NameLen))
- printCentered(math.floor(h/2) +6, PadString(" ",NameLen))
- Screen.setCursorPos(1, math.floor(h/2) +0)
- Screen.write("10 By")
- Screen.setCursorPos(1, math.floor(h/2) +1)
- Screen.write("Choose Able")
- Screen.setCursorPos(1, math.floor(h/2) +3)
- Screen.write("D = Dirt")
- Screen.setCursorPos(1, math.floor(h/2) +4)
- Screen.write("W = Water")
- elseif nMakeNormaleFarmLandsOption == 3 then
- printCentered(math.floor(h/2) -4, PadString("Choose Farm",NameLen))
- printCentered(math.floor(h/2) -2, PadString(" ",NameLen))
- printCentered(math.floor(h/2) -1, PadString("DDDDWDDDD",NameLen))
- printCentered(math.floor(h/2) +0, PadString("DDDDWDDDD",NameLen))
- printCentered(math.floor(h/2) +1, PadString("DDDDWDDDD",NameLen))
- printCentered(math.floor(h/2) +2, PadString(".........",NameLen))
- printCentered(math.floor(h/2) +3, PadString(" ",NameLen))
- printCentered(math.floor(h/2) +4, PadString(" ",NameLen))
- printCentered(math.floor(h/2) +5, PadString(" ",NameLen))
- printCentered(math.floor(h/2) +6, PadString(" ",NameLen))
- Screen.setCursorPos(1, math.floor(h/2) +0)
- Screen.write("9 By")
- Screen.setCursorPos(1, math.floor(h/2) +1)
- Screen.write("Choose Able")
- Screen.setCursorPos(1, math.floor(h/2) +3)
- Screen.write("D = Dirt")
- Screen.setCursorPos(1, math.floor(h/2) +4)
- Screen.write("W = Water")
- end
- end
- function drawFarmFarmingMenu()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Screen.setCursorPos(w-NameLen, 1)
- if nFarmFarmingOption == 1 then
- Screen.write("Do All")
- elseif nFarmFarmingOption == 2 then
- Screen.write("Plow")
- elseif nFarmFarmingOption == 3 then
- Screen.write("Plant Seeds")
- elseif nFarmFarmingOption == 3 then
- Screen.write("Harvest")
- else
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawFarmFarmingFrontend()
- printCentered(math.floor(h/2) -3, PadString(" Farming Menu",NameLen))
- printCentered(math.floor(h/2) -1, ((nFarmFarmingOption == 1) and string.format("%s%s",PadString("[ All",NameLen-1),"]") or PadString(" All",NameLen)))
- printCentered(math.floor(h/2) +0, ((nFarmFarmingOption == 2) and string.format("%s%s",PadString("[ Plow",NameLen-1),"]") or PadString(" Plow",NameLen)))
- printCentered(math.floor(h/2) +1, ((nFarmFarmingOption == 3) and string.format("%s%s",PadString("[ Plant",NameLen-1),"]") or PadString(" Plant",NameLen)))
- printCentered(math.floor(h/2) +2, ((nFarmFarmingOption == 4) and string.format("%s%s",PadString("[ Harvest",NameLen-1),"]") or PadString(" Harvest",NameLen)))
- end
- function drawPlowFrontend()
- Screen.clear()
- printCentered(1, "What Farm:")
- local I = -3
- local Farms = Turtle.Data.Farms.Normale.Overworld
- if Farms then
- for i = 1, #Farms do
- printCentered(math.floor(h/2) +I, ((nPlowOption == i) and string.format("%s%s","[ Farm"..i.." Cor: X: "..Farms[i].Cor.X.." Y: "..Farms[i].Cor.Y.." Z: "..Farms[i].Cor.Z, "]") or " Farm"..i.." Cor: X: "..Farms[i].Cor.X.." Y: "..Farms[i].Cor.Y.." Z: "..Farms[i].Cor.Z))
- I = I + 1
- end
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawNetherFrontend()
- Screen.clear()
- printCentered(1, "What Farm:")
- local I = -3
- local Farms = Turtle.Data.Farms.Normale.Nether
- if Farms then
- for i = 1, #Farms do
- printCentered(math.floor(h/2) +I, ((nPlowOption == i) and string.format("%s%s","[ NetherFarm"..i.." Cor: X: "..Farms[i].Cor.X.." Y: "..Farms[i].Cor.Y.." Z: "..Farms[i].Cor.Z, "]") or " NetherFarm"..i.." Cor: X: "..Farms[i].Cor.X.." Y: "..Farms[i].Cor.Y.." Z: "..Farms[i].Cor.Z))
- I = I + 1
- end
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawPlantMenu()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- Screen.write("Name: "..Turtle.System.TurtleName)
- Screen.setCursorPos(w-NameLen, 1)
- if nPlantOption == 1 then
- Screen.write("Wheat")
- elseif nPlantOption == 2 then
- Screen.write("Beetroot")
- elseif nPlantOption == 3 then
- Screen.write("Carrot")
- elseif nPlantOption == 4 then
- Screen.write("Potato")
- elseif nPlantOption == 5 then
- Screen.write("Wart")
- else
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- function drawPlantFrontend()
- printCentered(math.floor(h/2) -3, PadString(" Plant Menu",NameLen))
- printCentered(math.floor(h/2) -1, ((nPlantOption == 1) and string.format("%s%s",PadString("[ Wheat",NameLen-1),"]") or PadString(" Wheat",NameLen)))
- printCentered(math.floor(h/2) +0, ((nPlantOption == 2) and string.format("%s%s",PadString("[ Beetroot",NameLen-1),"]") or PadString(" Beetroot",NameLen)))
- printCentered(math.floor(h/2) +1, ((nPlantOption == 3) and string.format("%s%s",PadString("[ Carrot",NameLen-1),"]") or PadString(" Carrot",NameLen)))
- printCentered(math.floor(h/2) +2, ((nPlantOption == 4) and string.format("%s%s",PadString("[ Potato",NameLen-1),"]") or PadString(" Potato",NameLen)))
- printCentered(math.floor(h/2) +3, ((nPlantOption == 5) and string.format("%s%s",PadString("[ Wart",NameLen-1),"]") or PadString(" Wart",NameLen)))
- end
- function drawHarvestFrontend()
- Screen.clear()
- printCentered(1, "What Farm:")
- local I = -3
- local Farms = Turtle.Data.Farms.Normale.Overworld
- local A = 1
- if Farms then
- for i = 1, #Farms do
- printCentered(math.floor(h/2) +I, ((nHarvestOption == A) and string.format("%s%s","[ Farm"..i.." Cor: X: "..Farms[i].Cor.X.." Y: "..Farms[i].Cor.Y.." Z: "..Farms[i].Cor.Z, "]") or " Farm"..i.." Cor: X: "..Farms[i].Cor.X.." Y: "..Farms[i].Cor.Y.." Z: "..Farms[i].Cor.Z))
- I = I + 1
- A = A + 1
- end
- end
- local Farms = Turtle.Data.Farms.Normale.Nether
- if Farms then
- for i = 1, #Farms do
- printCentered(math.floor(h/2) +I, ((nPlowOption == A) and string.format("%s%s","[ NetherFarm"..i.." Cor: X: "..Farms[i].Cor.X.." Y: "..Farms[i].Cor.Y.." Z: "..Farms[i].Cor.Z, "]") or " NetherFarm"..i.." Cor: X: "..Farms[i].Cor.X.." Y: "..Farms[i].Cor.Y.." Z: "..Farms[i].Cor.Z))
- I = I + 1
- A = A + 1
- end
- end
- SetColors(Color.White, Color.Black)
- Screen.setCursorPos(1, h)
- Screen.write("Press 'B' to go back.")
- SetColors(Color.Black, Color.White)
- end
- -- Other Functions
- -- Movements
- function InspectItem(Side)
- if Side == "forward" then
- local Succes, Table = Turtle.Inspect.Forward()
- if Succes then
- if string.find(Table.name, "turtle") then
- return "turtle"
- else
- local NotFound = "true"
- for Name, Data in pairs(BlackListedDigging) do
- for i, name in ipairs(Data) do
- if string.find(Table.name, name) then
- NotFound = "false"
- break
- end
- end
- if NotFound == "false" then
- break
- end
- end
- return NotFound
- end
- else
- return "true"
- end
- elseif Side == "up" then
- local Succes, Table = Turtle.Inspect.Up()
- if Succes then
- if string.find(Table.name, "turtle") then
- return "turtle"
- else
- local NotFound = "true"
- for Name, Data in pairs(BlackListedDigging) do
- for i, name in ipairs(Data) do
- if string.find(Table.name, name) then
- NotFound = "false"
- break
- end
- end
- if NotFound == "false" then
- break
- end
- end
- return NotFound
- end
- else
- return "true"
- end
- elseif Side == "down" then
- local Succes, Table = Turtle.Inspect.Down()
- if Succes then
- if string.find(Table.name, "turtle") then
- return "turtle"
- else
- local NotFound = "true"
- for Name, Data in pairs(BlackListedDigging) do
- for i, name in ipairs(Data) do
- if string.find(Table.name, name) then
- NotFound = "false"
- break
- end
- end
- if NotFound == "false" then
- break
- end
- end
- return NotFound
- end
- else
- return "true"
- end
- end
- end
- function GetOrientNames(R)
- if R == 1 then
- return "North"
- elseif R == 2 then
- return "East"
- elseif R == 3 then
- return "South"
- elseif R == 4 then
- return "West"
- end
- end
- function TurnDirection(O)
- while Turtle.Data.Cor.R ~= O do
- TurnLeft()
- end
- end
- function TurnLeft()
- Turtle.Data.Cor.R = Turtle.Data.Cor.R - 1
- Turtle.Data.Cor.R = (Turtle.Data.Cor.R - 1) % 4
- Turtle.Data.Cor.R = Turtle.Data.Cor.R + 1
- Turtle.Move.Left()
- end
- function TurnRight()
- Turtle.Data.Cor.R = Turtle.Data.Cor.R - 1
- Turtle.Data.Cor.R = (Turtle.Data.Cor.R + 1) % 4
- Turtle.Data.Cor.R = Turtle.Data.Cor.R + 1
- Turtle.Move.Right()
- end
- function DigForward()
- while Turtle.Detect.Forward() do
- Turtle.Dig.Forward()
- end
- end
- function DigUp()
- while Turtle.Detect.Up() do
- Turtle.Dig.Up()
- end
- end
- function DigDown()
- while Turtle.Detect.Down() do
- Turtle.Dig.Down()
- end
- end
- function Forward()
- local CanMove = InspectItem("forward")
- local Moved = false
- while CanMove ~= "true" do
- if CanMove == "turtle" then
- sleep(2)
- elseif CanMove == "false" then
- if InspectItem("up") == "true" then
- DigUp()
- Moved = Turtle.Move.Up()
- if Moved then
- Turtle.Data.Cor.Y = Turtle.Data.Cor.Y + 1
- for i = 1, 2 do
- Moved = false
- DigForward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- end
- end
- if Moved then
- Moved = false
- DigDown()
- Moved = Turtle.Move.Down()
- if Moved then
- Turtle.Data.Cor.Y = Turtle.Data.Cor.Y - 1
- end
- end
- end
- elseif InspectItem("down") == "true" then
- DigDown()
- Moved = Turtle.Move.Down()
- if Moved then
- Turtle.Data.Cor.Y = Turtle.Data.Cor.Y - 1
- for i = 1, 2 do
- Moved = false
- DigForward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- end
- end
- if Moved then
- Moved = false
- DigUp()
- Moved = Turtle.Move.Up()
- if Moved then
- Turtle.Data.Cor.Y = Turtle.Data.Cor.Y + 1
- end
- end
- end
- end
- end
- CanMove = InspectItem("forward")
- end
- Moved = false
- DigForward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- end
- return Moved
- end
- function Back()
- local Moved = Turtle.Move.Back()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X - xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z - zDiff[Turtle.Data.Cor.R]
- end
- return Moved
- end
- function Up()
- local CanMove = InspectItem("up")
- local Moved = false
- while CanMove ~= "true" do
- if CanMove == "turtle" then
- sleep(2)
- elseif CanMove == "false" then
- if InspectItem("forward") == "true" then
- Turtle.Dig.Forward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- for i = 1, 2 do
- Moved = false
- DigUp()
- Moved = Turtle.Move.Up()
- if Moved then
- Turtle.Data.Cor.Y = Turtle.Data.Cor.Y + 1
- end
- end
- if Moved then
- Moved = false
- for ii = 1, 2 do
- TurnLeft()
- end
- DigForward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- for ii = 1, 2 do
- TurnRight()
- end
- end
- end
- end
- else
- local SR = Turtle.Data.Cor.R34DY
- if InspectItem("forward") == "true" then
- Turtle.Dig.Forward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- for i = 1, 2 do
- Moved = false
- DigUp()
- Moved = Turtle.Move.Up()
- if Moved then
- Turtle.Data.Cor.Y = Turtle.Data.Cor.Y + 1
- end
- end
- if Moved then
- Moved = false
- for ii = 1, 2 do
- TurnLeft()
- end
- DigForward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- for ii = 1, 2 do
- TurnRight()
- end
- end
- end
- end
- end
- TurnDirection(SR)
- end
- end
- CanMove = InspectItem("up")
- end
- Moved = false
- DigUp()
- Moved = Turtle.Move.Up()
- if Moved then
- Turtle.Data.Cor.Y = Turtle.Data.Cor.Y + 1
- end
- return Moved
- end
- function Down()
- local CanMove = InspectItem("down")
- local Moved = false
- while CanMove ~= "true" do
- if CanMove == "turtle" then
- sleep(2)
- elseif CanMove == "false" then
- if InspectItem("forward") == "true" then
- DigForward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- for i = 1, 2 do
- Moved = false
- DigDown()
- Moved = Turtle.Move.Down()
- if Moved then
- Turtle.Data.Cor.Y = Turtle.Data.Cor.Y - 1
- end
- end
- if Moved then
- Moved = false
- for ii = 1, 2 do
- TurnLeft()
- end
- DigForward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- for ii = 1, 2 do
- TurnRight()
- end
- end
- end
- end
- else
- local SR = Turtle.Data.Cor.R34DY
- if InspectItem("forward") == "true" then
- DigForward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- for i = 1, 2 do
- Moved = false
- DigDown()
- Moved = Turtle.Move.Down()
- if Moved then
- Turtle.Data.Cor.Y = Turtle.Data.Cor.Y - 1
- end
- end
- if Moved then
- Moved = false
- for ii = 1, 2 do
- TurnLeft()
- end
- DigForward()
- Moved = Turtle.Move.Forward()
- if Moved then
- Turtle.Data.Cor.X = Turtle.Data.Cor.X + xDiff[Turtle.Data.Cor.R]
- Turtle.Data.Cor.Z = Turtle.Data.Cor.Z + zDiff[Turtle.Data.Cor.R]
- for ii = 1, 2 do
- TurnRight()
- end
- end
- end
- end
- end
- TurnDirection(SR)
- end
- end
- CanMove = InspectItem("down")
- end
- Moved = false
- DigDown()
- Moved = Turtle.Move.Down()
- if Moved then
- Turtle.Data.Cor.Y = Turtle.Data.Cor.Y - 1
- end
- return Moved
- end
- local ButtonForward = Button.setTable("W", Forward, 5, 7, 5, 7)
- local ButtonBack = Button.setTable("S", Back, 5, 7, 8, 10)
- local ButtonLeft = Button.setTable("A", TurnLeft, 2, 4, 8, 10)
- local ButtonRight = Button.setTable("D", TurnRight, 8, 10, 8, 10)
- local ButtonUp = Button.setTable("R", Up, 12, 14, 5, 7)
- local ButtonDown = Button.setTable("F", Down, 12, 14, 8, 10)
- -- Inspect
- function Inspect(Side)
- if Side == "up" then
- local SuccesUp, Data = Turtle.Inspect.Up()
- if not(SuccesUp) then
- Turtle.Inspect.State.Up = {}
- Turtle.Inspect.State.Up.name = "air"
- else
- Turtle.Inspect.State.Up = {}
- Turtle.Inspect.State.Up = Data
- Turtle.Inspect.State.Up.name = string.sub(Data.name, string.find(Data.name, ":")+1)
- end
- elseif Side == "forward" then
- local SuccesForward, Data = Turtle.Inspect.Forward()
- if not(SuccesForward) then
- Turtle.Inspect.State.Forward = {}
- Turtle.Inspect.State.Forward.name = "air"
- else
- Turtle.Inspect.State.Forward = {}
- Turtle.Inspect.State.Forward = Data
- Turtle.Inspect.State.Forward.name = string.sub(Data.name, string.find(Data.name, ":")+1)
- end
- elseif Side == "down" then
- local SuccesDown, Data = Turtle.Inspect.Down()
- if not(SuccesDown) then
- Turtle.Inspect.State.Down = {}
- Turtle.Inspect.State.Down.name = "air"
- else
- Turtle.Inspect.State.Down = {}
- Turtle.Inspect.State.Down = Data
- Turtle.Inspect.State.Down.name = string.sub(Data.name, string.find(Data.name, ":")+1)
- end
- end
- end
- -- GoHome and GoTo Functions
- function GoHome()
- while Turtle.Data.Cor.Y < Turtle.Data.Height.Travel do
- SendToServer("Going Home", 0)
- Up()
- end
- while Turtle.Data.Cor.Y > Turtle.Data.Height.Travel do
- SendToServer("Going Home", 0)
- Down()
- end
- if Turtle.Data.Cor.X < Turtle.Data.Home.X then
- TurnDirection(2)
- while Turtle.Data.Cor.X < Turtle.Data.Home.X do
- SendToServer("Going Home", 0)
- Forward()
- end
- end
- if Turtle.Data.Cor.X > Turtle.Data.Home.X then
- TurnDirection(4)
- while Turtle.Data.Cor.X > Turtle.Data.Home.X do
- SendToServer("Going Home", 0)
- Forward()
- end
- end
- if Turtle.Data.Cor.Z < Turtle.Data.Home.Z then
- TurnDirection(3)
- while Turtle.Data.Cor.Z < Turtle.Data.Home.Z do
- SendToServer("Going Home", 0)
- Forward()
- end
- end
- if Turtle.Data.Cor.Z > Turtle.Data.Home.Z then
- TurnDirection(1)
- while Turtle.Data.Cor.Z > Turtle.Data.Home.Z do
- SendToServer("Going Home", 0)
- Forward()
- end
- end
- if Turtle.Data.Cor.X < Turtle.Data.Home.X then
- TurnDirection(2)
- while Turtle.Data.Cor.X < Turtle.Data.Home.X do
- SendToServer("Going Home", 0)
- Forward()
- end
- end
- if Turtle.Data.Cor.X > Turtle.Data.Home.X then
- TurnDirection(4)
- while Turtle.Data.Cor.X > Turtle.Data.Home.X do
- SendToServer("Going Home", 0)
- Forward()
- end
- end
- if Turtle.Data.Cor.Z < Turtle.Data.Home.Z then
- TurnDirection(3)
- while Turtle.Data.Cor.Z < Turtle.Data.Home.Z do
- SendToServer("Going Home", 0)
- Forward()
- end
- end
- if Turtle.Data.Cor.Z > Turtle.Data.Home.Z then
- TurnDirection(1)
- while Turtle.Data.Cor.Z > Turtle.Data.Home.Z do
- SendToServer("Going Home", 0)
- Forward()
- end
- end
- while Turtle.Data.Cor.Y < Turtle.Data.Home.Y do
- SendToServer("Going Home", 0)
- Up()
- end
- while Turtle.Data.Cor.Y > Turtle.Data.Home.Y do
- SendToServer("Going Home", 0)
- Down()
- end
- TurnDirection(Turtle.Data.Home.R)
- end
- function GoTo(GX, GY, GZ)
- if type(GX) == "table" then
- GZ = GX.Z
- GY = GX.Y
- GX = GX.X
- end
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local OldFuel = Turtle.Data.FuelLevel
- for i = 1, 16, 1 do
- Turtle.Slot.Select(i)
- Turtle.Fuel.Refuel()
- end
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel == OldFuel or Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- if Turtle.Data.Cor.X == Turtle.Data.Home.X and Turtle.Data.Cor.Y == Turtle.Data.Home.Y and Turtle.Data.Cor.Z == Turtle.Data.Home.Z and Turtle.Data.Cor.R == Turtle.Data.Home.R then
- Refuel()
- else
- Fuel()
- end
- Turtle.Data.FuelLevel = GetFuel()
- while Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel do
- Screen.clear()
- if Screen.isColor then
- C1 = Color.Red
- C2 = Color.Black
- end
- SetColors(C1, C2)
- printCentered(math.floor(h/2),"Cant Refuel Give Coal And Press Enter!")
- SetColors(Color.Black, Color.White)
- SendToServer("Low Fuel", 0)
- local Event, p1, p2 = System.pullEvent("key")
- ReFuel()
- Turtle.Data.FuelLevel = GetFuel()
- end
- end
- end
- while Turtle.Data.Cor.Y < GY do
- SendToServer("Goto", 0)
- Up()
- end
- while Turtle.Data.Cor.Y > GY do
- SendToServer("Goto", 0)
- Down()
- end
- if Turtle.Data.Cor.X < GX then
- TurnDirection(2)
- while Turtle.Data.Cor.X < GX do
- SendToServer("Goto", 0)
- CheckBlock()
- Forward()
- end
- end
- if Turtle.Data.Cor.X > GX then
- TurnDirection(4)
- while Turtle.Data.Cor.X > GX do
- SendToServer("Goto", 0)
- CheckBlock()
- Forward()
- end
- end
- if Turtle.Data.Cor.Z < GZ then
- TurnDirection(3)
- while Turtle.Data.Cor.Z < GZ do
- SendToServer("Goto", 0)
- CheckBlock()
- Forward()
- end
- end
- if Turtle.Data.Cor.Z > GZ then
- TurnDirection(1)
- while Turtle.Data.Cor.Z > GZ do
- SendToServer("Goto", 0)
- CheckBlock()
- Forward()
- end
- end
- if Turtle.Data.Cor.X < GX then
- TurnDirection(2)
- while Turtle.Data.Cor.X < GX do
- SendToServer("Goto", 0)
- CheckBlock()
- Forward()
- end
- end
- if Turtle.Data.Cor.X > GX then
- TurnDirection(4)
- while Turtle.Data.Cor.X > GX do
- SendToServer("Goto", 0)
- CheckBlock()
- Forward()
- end
- end
- if Turtle.Data.Cor.Z < GZ then
- TurnDirection(3)
- while Turtle.Data.Cor.Z < GZ do
- SendToServer("Goto", 0)
- CheckBlock()
- Forward()
- end
- end
- if Turtle.Data.Cor.Z > GZ then
- TurnDirection(1)
- while Turtle.Data.Cor.Z > GZ do
- SendToServer("Goto", 0)
- CheckBlock()
- Forward()
- end
- end
- end
- -- Send Modem Functions
- function SendToServer(Text, Todo)
- Turtle.Data.FuelLevel = GetFuel()
- Turtle.Data.Slot = {}
- for i = 1, 16 do
- Turtle.Data.Slot[i] = {}
- Turtle.Data.Slot[i].Count = {}
- Turtle.Data.Slot[i].Data = {}
- Turtle.Data.Slot[i].Count = Turtle.Slot.Item.Count(i)
- Turtle.Data.Slot[i].Data = Turtle.Slot.Item.Detail(i)
- end
- local Data = {Name = System.getComputerLabel(), Cor = Turtle.Data.Cor, FuelLevel = Turtle.Data.FuelLevel, Doing = Text, LTG = Todo, GroupState = Turtle.System.GroupState, Inspect = Turtle.Inspect.State, Compare = Turtle.Compare.State, Detect = Turtle.Detect.State, SlotSelected = Turtle.Slot.Selected(), Slot = Turtle.Data.Slot}
- local ADATA = {What = "Command", Command = "/UPD4T3/", Data = Data}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(ADATA))
- end
- -- Tool Functions
- function ToolCheck(T00l)
- Turtle.Slot.Select(1)
- Turtle.Equip.Left()
- local Info = Turtle.Slot.Item.Detail(1)
- Turtle.Equip.Left()
- if Info then
- if Info.name == T00l then
- return true
- else
- return false
- end
- else
- return false
- end
- end
- function GetTool(T000l)
- local Check = ToolCheck(T000l)
- if not(Check) then
- getOutInventory(T000l)
- Turtle.Equip.Left()
- Check = true
- end
- while not(Check) do
- Turtle.Slot.Select(1)
- Turtle.Equip.Left()
- Turtle.Slot.Select(1)
- Screen.clear()
- Screen.setCursorPos(1, math.floor(h/2)-1)
- print("No tool found!!! Give tool in slot 1: "..T000l)
- print("Then press any key. ")
- local Event, p1, p2, p3 = System.pullEvent("key")
- Turtle.Slot.Select(1)
- Turtle.Equip.Left()
- sleep(1)
- Check = ToolCheck(T000l)
- end
- end
- function PutToolAway()
- Turtle.Slot.Select(1)
- Turtle.Equip.Left()
- Turtle.Drop.Forward()
- end
- function CheckBlock()
- Inspect("up")
- Inspect("forward")
- Inspect("down")
- for what, whatdata in pairs(OreLib) do
- for number, name in ipairs(whatdata) do
- if Turtle.Inspect.State.Up.name == name then
- Turtle.Dig.Up()
- end
- if Turtle.Inspect.State.Down.name == name then
- Turtle.Dig.Down()
- end
- if Turtle.Inspect.State.Forward.name == name then
- Turtle.Dig.Forward()
- end
- end
- end
- end
- function setComputerName(name)
- oldName = Turtle.System.TurtleName
- System.setComputerLabel(name)
- end
- function resetComputerName()
- if oldName then
- System.setComputerLabel(oldName)
- end
- end
- function getTravelHeight(id)
- Send(id, Turtle.System.Modem.OwnID, Pack(Turtle.Data.Height.Travel))
- end
- -- Inventory Function
- function getOutInventory(name)
- local Inventory = Per.wrap("front")
- if Inventory then
- local State = false
- local a = 0
- for Slot = 1, Inventory.size() do
- local Item = Inventory.getItemDetail(Slot)
- if Item then
- if Item.name == name then
- Inventory.pushItems("back", Slot)
- a = a + 1
- State = true
- if a == 2 then break end
- end
- end
- end
- TurnLeft()
- TurnLeft()
- local Staat = true
- while Staat do
- Staat = Turtle.Suck.Forward()
- end
- TurnRight()
- TurnRight()
- return State
- else
- return false
- end
- end
- local StripMineState = false
- function MakeQuarry(Data)
- Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z = Data.X, Data.Y, Data.Z
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z)
- end
- function StripMineStateStop()
- SendToServer("Strip Mine off", 0)
- StripMineState = false
- end
- function StripMine()
- local CommandList = {
- ["W"] = Forward,
- ["S"] = Back,
- ["A"] = TurnLeft,
- ["D"] = TurnRight,
- ["R"] = Up,
- ["F"] = Down,
- ["TD"] = TurnDirection,
- ["DF"] = DigForward,
- ["DU"] = DigUp,
- ["DD"] = DigDown,
- ["PF"] = Turtle.Place.Forward,
- ["PU"] = Turtle.Place.Up,
- ["PD"] = Turtle.Place.Down,
- ["SF"] = Turtle.Suck.Forward,
- ["SU"] = Turtle.Suck.Up,
- ["SD"] = Turtle.Suck.Down,
- ["DRF"] = Turtle.Drop.Forward,
- ["DRU"] = Turtle.Drop.Up,
- ["DRD"] = Turtle.Drop.Down,
- ["DFW"] = {DigForward, Forward},
- ["DUR"] = {DigUp, Up},
- ["DDF"] = {DigDown, Down},
- ["WDF"] = {Forward, DigForward},
- ["RDU"] = {Up, DigUp},
- ["FDD"] = {Down, DigDown},
- ["Fuel"] = Fuel,
- ["NS"] = setComputerName,
- ["NR"] = resetComputerName,
- ["GT"] = GetTool,
- ["PTA"] = PutToolAway,
- ["INV"] = EmptyInventory,
- ["CINV"] = CheckEmptyInventory,
- ["Home"] = GoHome,
- ["GoTo"] = GoTo,
- ["StripMine"] = StripMine,
- ["StripMineDone"] = StripMineStateStop,
- ["MQ"] = MakeQuarry,
- ["GTH"] = getTravelHeight
- }
- SendToServer("Strip Mine", 0)
- StripMineState = true
- while StripMineState do
- local Event, p1, p2, p3, p4, p5 = System.pullEvent("modem_message")
- local Data = UnPack(p4)
- if Data.What == "Function" then
- if type(Data.Function) == "string" then
- if type(CommandList[Data.Function]) == "function" then
- if Data.Data then
- CommandList[Data.Function](Data.Data)
- else
- CommandList[Data.Function]()
- end
- CheckBlock()
- SendToServer(Data.Function, 0)
- elseif type(CommandList[Data.Function]) == "table" then
- for i=1,#CommandList[Data.Function] do
- if Data.Data then
- CommandList[Data.Function][i](Data.Data)
- else
- CommandList[Data.Function][i]()
- end
- CheckBlock()
- SendToServer(Data.Function, 0)
- end
- end
- elseif type(Data.Function) == "table" then
- for i=1,#Data.Function do
- if type(CommandList[Data.Function[i]]) == "function" then
- if Data.Data then
- CommandList[Data.Function[i]](Data.Data)
- else
- CommandList[Data.Function[i]]()
- end
- CheckBlock()
- SendToServer(Data.Function[i], 0)
- elseif type(CommandList[Data.Function[i]]) == "table" then
- for ii=1,#CommandList[Data.Function[i]] do
- if Data.Data then
- CommandList[Data.Function[i]][ii](Data.Data)
- else
- CommandList[Data.Function[i]][ii]()
- end
- CheckBlock()
- SendToServer(Data.Function[i], 0)
- end
- end
- end
- end
- end
- CheckBlock()
- SendToServer("Done", 0)
- Send(p3, Turtle.System.Modem.OwnID, "Done")
- end
- end
- -- Commands List for Functions on modem_message
- local CommandList = {
- ["W"] = Forward,
- ["S"] = Back,
- ["A"] = TurnLeft,
- ["D"] = TurnRight,
- ["R"] = Up,
- ["F"] = Down,
- ["TD"] = TurnDirection,
- ["DF"] = DigForward,
- ["DU"] = DigUp,
- ["DD"] = DigDown,
- ["PF"] = Turtle.Place.Forward,
- ["PU"] = Turtle.Place.Up,
- ["PD"] = Turtle.Place.Down,
- ["SF"] = Turtle.Suck.Forward,
- ["SU"] = Turtle.Suck.Up,
- ["SD"] = Turtle.Suck.Down,
- ["DRF"] = Turtle.Drop.Forward,
- ["DRU"] = Turtle.Drop.Up,
- ["DRD"] = Turtle.Drop.Down,
- ["DFW"] = {DigForward, Forward},
- ["DUR"] = {DigUp, Up},
- ["DDF"] = {DigDown, Down},
- ["WDF"] = {Forward, DigForward},
- ["RDU"] = {Up, DigUp},
- ["FDD"] = {Down, DigDown},
- ["Fuel"] = Fuel,
- ["NS"] = setComputerName,
- ["NR"] = resetComputerName,
- ["GT"] = GetTool,
- ["PTA"] = PutToolAway,
- ["INV"] = EmptyInventory,
- ["CINV"] = CheckEmptyInventory,
- ["Home"] = GoHome,
- ["GoTo"] = GoTo,
- ["StripMine"] = StripMine,
- ["StripMineDone"] = StripMineStateStop,
- ["MQ"] = MakeQuarry,
- ["GTH"] = getTravelHeight
- }
- -- On Message Funtion
- function onMessage(Data, Sender)
- SendToServer("Modem Message", 0)
- if Data.What == "Function" then
- if type(Data.Function) == "string" then
- if type(CommandList[Data.Function]) == "function" then
- if Data.Data then
- CommandList[Data.Function](Data.Data)
- else
- CommandList[Data.Function]()
- end
- Inspect("up")
- Inspect("forward")
- Inspect("down")
- SendToServer(Data.Function, 0)
- elseif type(CommandList[Data.Function]) == "table" then
- for i=1,#CommandList[Data.Function] do
- if Data.Data then
- CommandList[Data.Function][i](Data.Data)
- else
- CommandList[Data.Function][i]()
- end
- Inspect("up")
- Inspect("forward")
- Inspect("down")
- SendToServer(Data.Function, 0)
- end
- end
- elseif type(Data.Function) == "table" then
- for i=1,#Data.Function do
- if type(CommandList[Data.Function[i]]) == "function" then
- if Data.Data then
- CommandList[Data.Function[i]](Data.Data)
- else
- CommandList[Data.Function[i]]()
- end
- Inspect("up")
- Inspect("forward")
- Inspect("down")
- SendToServer(Data.Function[i], 0)
- elseif type(CommandList[Data.Function[i]]) == "table" then
- for ii=1,#CommandList[Data.Function[i]] do
- if Data.Data then
- CommandList[Data.Function[i]][ii](Data.Data)
- else
- CommandList[Data.Function[i]][ii]()
- end
- Inspect("up")
- Inspect("forward")
- Inspect("down")
- SendToServer(Data.Function[i], 0)
- end
- end
- end
- end
- Inspect("up")
- Inspect("forward")
- Inspect("down")
- SendToServer("Function", 0)
- elseif Data.What == "Command" then
- if Data.Command == "/ShutDown/" then
- SafeSettings()
- SafeBlackListedDigging()
- local Data = {What = "Command", Command = "/CH3CK0UT/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Data))
- System.shutdown()
- elseif Data.Command == "/ReBoot/" then
- SafeSettings()
- SafeBlackListedDigging()
- local Data = {What = "Command", Command = "/CH3CK0UT/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Data))
- System.reboot()
- elseif Data.Command == "/GroupState/" then
- if Turtle.System.GroupState then
- Turtle.System.GroupState = false
- elseif not(Turtle.System.GroupState) then
- Turtle.System.GroupState = true
- end
- SendToServer("Updating", 0)
- elseif Data.Command == "/ReFuel/" then
- ReFuel()
- SendToServer("Updating", 0)
- elseif Data.Command == "/SelectSlot/" then
- Turtle.Slot.Select(Data.Data)
- elseif Data.Command == "/EqUip/" then
- if Data.Data == "left" then
- Turtle.Equip.Left()
- elseif Data.Data == "right" then
- Turtle.Equip.Right()
- end
- elseif Data.Command == "/TransferTo/" then
- Turtle.TransferTo(Data.Data)
- elseif Data.Command == "/CrAft/" then
- turtle.craft()
- elseif Data.Command == "/InSpect/" then
- if Data.Data == "forward" then
- local Succes, Data = Turtle.Inspect.Forward()
- if Succes then
- Turtle.Inspect.State.Forward = Data
- else
- Turtle.Inspect.State.Forward.name = "air"
- end
- elseif Data.Data == "up" then
- local Succes, Data = Turtle.Inspect.Up()
- if Succes then
- Turtle.Inspect.State.Up = Data
- else
- Turtle.Inspect.State.Up.name = "air"
- end
- elseif Data.Data == "down" then
- local Succes, Data = Turtle.Inspect.Down()
- if Succes then
- Turtle.Inspect.State.Down = Data
- else
- Turtle.Inspect.State.Down.name = "air"
- end
- end
- SendToServer("Updating", 0)
- elseif Data.Command == "PrintLog" then
- PrintLog()
- elseif Data.Command == "ReSet" then
- local Data = {What = "Command", Command = "/CH3CK0UT/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Data))
- local file = fs.exists("/OS/.Data/.Settings.set")
- if file then
- fs.delete("/OS/.Data/.Settings.set")
- System.reboot()
- end
- elseif Data.Command == "/AtTack/" then
- if Data.Data == "forward" then
- Turtle.Attack.Forward()
- elseif Data.Data == "up" then
- Turtle.Attack.Up()
- elseif Data.Data == "down" then
- Turtle.Attack.Down()
- end
- elseif Data.Command == "/DiG/" then
- if Data.Data == "forward" then
- Turtle.Dig.Forward()
- elseif Data.Data == "up" then
- Turtle.Dig.Up()
- elseif Data.Data == "down" then
- Turtle.Dig.Down()
- end
- SendToServer("Updating", 0)
- elseif Data.Command == "/SuCk/" then
- if Data.Data == "forward" then
- Turtle.Suck.Forward()
- elseif Data.Data == "up" then
- Turtle.Suck.Up()
- elseif Data.Data == "down" then
- Turtle.Suck.Down()
- end
- elseif Data.Command == "/DrOp/" then
- if Data.Data == "forward" then
- Turtle.Drop.Forward()
- elseif Data.Data == "up" then
- Turtle.Drop.Up()
- elseif Data.Data == "down" then
- Turtle.Drop.Down()
- end
- elseif Data.Command == "/PlAce/" then
- if Data.Data == "forward" then
- Turtle.Place.Forward()
- elseif Data.Data == "up" then
- Turtle.Place.Up()
- elseif Data.Data == "down" then
- Turtle.Place.Down()
- end
- SendToServer("Updating", 0)
- elseif Data.Command == "/GoTo/" then
- Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z = Data.Data.X, Data.Data.Y, Data.Data.Z
- GoTo(Data.Data.X, Turtle.Data.Height.Travel, Data.Data.Z)
- GoTo(Data.Data.X, Data.Data.Y, Data.Data.Z)
- SendToServer("Updating", 0)
- elseif Data.Command == "/GoHome/" then
- GoHome()
- SendToServer("Updating", 0)
- elseif Data.Command == "/TurnDirection/" then
- Turtle.Data.Quarry.R = Data.Data
- TurnDirection(Data.Data)
- elseif Data.Command == "/EmptyInventory/" then
- EmptyInventory()
- elseif Data.Command == "/QuArry/" then
- Turtle.Data.Quarry.X = Data.Data.X
- Turtle.Data.Quarry.Y = Data.Data.Y
- Turtle.Data.Quarry.Z = Data.Data.Z
- Turtle.Data.Quarry.Blocks = Data.Data.Blocks
- Turtle.Data.Quarry.Lines = Data.Data.Lines
- Turtle.Data.Quarry.Layers = Data.Data.Layers
- if Turtle.Data.Quarry.Y == 0 then
- Turtle.Data.Quarry.X = Turtle.Data.Cor.X
- Turtle.Data.Quarry.Y = Turtle.Data.Cor.Y
- Turtle.Data.Quarry.Z = Turtle.Data.Cor.Z
- end
- Screen.clear()
- printCentered(math.floor(h/2), "Quarry")
- DigQuarry(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z, Turtle.Data.Quarry.Blocks, Turtle.Data.Quarry.Lines, Turtle.Data.Quarry.Layers)
- Turtle.Data.Quarry.X = 0
- Turtle.Data.Quarry.Y = 0
- Turtle.Data.Quarry.Z = 0
- Turtle.Data.Quarry.Blocks = 0
- Turtle.Data.Quarry.Lines = 0
- Turtle.Data.Quarry.Layers = 0
- elseif Data.Command == "/TuNnel/" then
- Turtle.Data.Quarry.X = Data.Data.X
- Turtle.Data.Quarry.Y = Data.Data.Y
- Turtle.Data.Quarry.Z = Data.Data.Z
- Turtle.Data.Quarry.R = Data.Data.R
- Turtle.Data.Quarry.Blocks = Data.Data.Blocks
- if Turtle.Data.Quarry.Y == 0 then
- Turtle.Data.Quarry.X = Turtle.Data.Cor.X
- Turtle.Data.Quarry.Y = Turtle.Data.Cor.Y
- Turtle.Data.Quarry.Z = Turtle.Data.Cor.Z
- end
- Screen.clear()
- printCentered(math.floor(h/2), "Tunnel 3 By 3")
- DigTunnel3BY3(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z, Turtle.Data.Quarry.R, Turtle.Data.Quarry.Blocks)
- Turtle.Data.Quarry.X = 0
- Turtle.Data.Quarry.Y = 0
- Turtle.Data.Quarry.Z = 0
- Turtle.Data.Quarry.R = 0
- Turtle.Data.Quarry.Blocks = 0
- elseif Data.Command == "/TreeFarm/" then
- TreeFarm(Data.Data)
- elseif Data.Command == "/FaRm/" then
- Farm()
- elseif Data.Command == "/3DPrint/" then
- SendToServer("3DPrint", 0)
- shell.run("/Progs/3DPrint.lua")
- SendToServer("Done 3DPrint", 0)
- end
- SendToServer("Command", 0)
- end
- end
- -- Programs Funtions
- -- Quarry
- function DigLine(LineLength, Layyers)
- local Tog0 = calculateLayersToGo(Layyers)
- for i = 1,LineLength do
- local InvFull = Turtle.Slot.Item.Count(16) > 0
- if InvFull then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- Tog0 = calculateLayersToGo(Layyers)
- SendToServer("Inv. Full", Tog0)
- GoHome()
- EmptyInventory()
- Tog0 = calculateLayersToGo(Layyers)
- SendToServer("GoTo", Tog0)
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- Tog0 = calculateLayersToGo(Layyers)
- SendToServer("GoTo", Tog0)
- GoTo(SX, SY, SZ)
- Tog0 = calculateLayersToGo(Layyers)
- SendToServer("GoTo", Tog0)
- TurnDirection(SR)
- end
- Turtle.Data.FuelLevel = GetFuel()
- Tog0 = calculateLayersToGo(Layyers)
- SendToServer("Digging", Tog0)
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local OldFuel = Turtle.Data.FuelLevel
- for i = 1, 16, 1 do
- Turtle.Slot.Select(i)
- Turtle.Fuel.Refuel()
- end
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel == OldFuel or Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- Tog0 = calculateLayersToGo(Layyers)
- SendToServer("Low Fuel", Tog0)
- if Turtle.Data.Cor.X ~= Turtle.Data.Home.X or Turtle.Data.Cor.Y ~= Turtle.Data.Home.Y or Turtle.Data.Cor.Z ~= Turtle.Data.Home.Z then
- GoHome()
- end
- EmptyInventory()
- ReFuel()
- Tog0 = calculateLayersToGo(Layyers)
- SendToServer("GoTo", Tog0)
- GoTo(SX, Turtle.Data.Height,Travel, SZ)
- Tog0 = calculateLayersToGo(Layyers)
- SendToServer("GoTo", Tog0)
- GoTo(SX, SY, SZ)
- Tog0 = calculateLayersToGo(Layyers)
- SendToServer("GoTo", Tog0)
- TurnDirection(SR)
- end
- end
- Tog0 = calculateLayersToGo(Layyers)
- SendToServer("Digging", Tog0)
- Turtle.Slot.Select(1)
- DigForward()
- Forward()
- end
- end
- function DigLayer(LineLength, Lines, Laayers)
- local Tog0 = calculateLayersToGo(Laayers)
- for i = 1,Lines do
- DigLine(LineLength, Laayers)
- if (i%2) == 1 and i < Lines then
- SendToServer("Digging", Tog0)
- TurnRight()
- Tog0 = calculateLayersToGo(Laayers)
- SendToServer("Digging", Tog0)
- DigForward()
- Forward()
- Tog0 = calculateLayersToGo(Laayers)
- SendToServer("Digging", Tog0)
- TurnRight()
- Tog0 = calculateLayersToGo(Laayers)
- SendToServer("Digging", Tog0)
- elseif i < Lines then
- Tog0 = calculateLayersToGo(Laayers)
- SendToServer("Digging", Tog0)
- TurnLeft()
- Tog0 = calculateLayersToGo(Laayers)
- SendToServer("Digging", Tog0)
- DigForward()
- Forward()
- Tog0 = calculateLayersToGo(Laayers)
- SendToServer("Digging", Tog0)
- TurnLeft()
- Tog0 = calculateLayersToGo(Laayers)
- SendToServer("Digging", Tog0)
- end
- end
- Tog0 = calculateLayersToGo(Laayers)
- SendToServer("Digging", Tog0)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Cor.Y, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- Tog0 = calculateLayersToGo(Laayers)
- SendToServer("Digging", Tog0)
- DigDown()
- Down()
- Tog0 = calculateLayersToGo(Laayers)
- SendToServer("Digging", Tog0)
- end
- function DigQuarry(xTarget, yTarget, zTarget, LineLength, Lines, Llayers)
- Screen.clear()
- printCentered(math.floor(h/2), "Quarry")
- System.setComputerLabel(Turtle.System.TurtleName.."Quarry") -- Turtle name
- GetTool(Tool.PickAxe)
- Turtle.Slot.Select(1)
- local QuarryX = xTarget
- local QuarryZ = zTarget
- local QuarryY = yTarget
- local DAta = {Name = "Quarry", X = QuarryX, Y = QuarryY, Z = QuarryZ, Blocks = LineLength, Lines = Lines, Layers = Llayers}
- SafeLog(DAta)
- GoTo(QuarryX, Turtle.Data.Height.Travel, QuarryZ)
- GoTo(QuarryX, QuarryY, QuarryZ)
- TurnDirection(1)
- local Tog0 = calculateLayersToGo(Llayers)
- SendToServer("Digging", Tog0)
- DigDown()
- Down()
- for i = 1, Llayers do
- DigLayer(LineLength, Lines, Llayers)
- if Turtle.Data.Cor.Y <= Turtle.Data.Height.Min then
- break
- end
- end
- Tog0 = calculateLayersToGo(Llayers)
- SendToServer("Going Home", Tog0)
- System.setComputerLabel(Turtle.System.TurtleName) -- Turtle name
- GoHome()
- EmptyInventory()
- Turtle.Slot.Select(1)
- Tog0 = calculateLayersToGo(Llayers)
- SendToServer("Home", Tog0)
- PutToolAway()
- end
- -- Sub Dig
- function calculateLayersToGo(Layers)
- local Done = Turtle.Data.Quarry.Y - Turtle.Data.Cor.Y
- local LTG = Layers - Done
- return LTG
- end
- -- Tunnel 3X3
- function DigTunnel3BY3(xTarget, yTarget, zTarget, Orientation, TunnelLength)
- Screen.clear()
- printCentered(math.floor(h/2), "Tunnel 3 By 3")
- System.setComputerLabel(Turtle.System.TurtleName.."Tunnel_3X3") -- Turtle name
- GetTool(Tool.PickAxe)
- Turtle.Slot.Select(1)
- local QuarryX = xTarget
- local QuarryZ = zTarget
- local QuarryY = yTarget
- local DAta = {Name = "Tunnel_3X3", X = QuarryX, Y = QuarryY, Z = QuarryZ, Orientation = Orientation, Length = TunnelLength}
- SafeLog(DAta)
- GoTo(QuarryX, turtle.Data.Height.Travel, QuarryZ)
- GoTo(QuarryX, QuarryY, QuarryZ)
- TurnDirection(Orientation)
- for i = 1, TunnelLength do
- local LTG = TunnelLength - i
- SendToServer("Digging", LTG)
- local InvFull = Turtle.Slot.Item.Count(16) > 0
- if InvFull then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- SendToServer("Inv. Full", LTG)
- GoTo(QuarryX, QuarryY, QuarryZ)
- SendToServer("Inv. Full", LTG)
- GoHome()
- EmptyInventory()
- SendToServer("GoTo", LTG)
- GoTo(QuarryX, Turtle.Data.Height.Travel, QuarryZ)
- GoTo(QuarryX, QuarryY, QuarryZ)
- SendToServer("GoTo", LTG)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local OldFuel = Turtle.Data.FuelLevel
- for i = 1, 16, 1 do
- Turtle.Slot.Select(i)
- Turtle.Fuel.ReFuel()
- end
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel == OldFuel or Turtle.Data.FuelLevel < MinFuel then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- SendToServer("Low Fuel", LTG)
- if Turtle.Data.Cor.X ~= Turtle.Data.Home.X or Turtle.Data.Cor.Y ~= Turtle.Data.Home.Y or Turtle.Data.Cor.Z ~= Turtle.Data.Home.Z then
- GoHome()
- end
- EmptyInventory()
- ReFuel()
- SendToServer("GoTo", LTG)
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- SendToServer("GoTo", LTG)
- GoTo(SX, SY, SZ)
- SendToServer("GoTo", LTG)
- TurnDirection(SR)
- end
- end
- SendToServer("Digging", LTG)
- Turtle.Slot.Select(1)
- DigForward()
- Forward()
- SendToServer(LTG, "Digging", LTG)
- TurnLeft()
- DigForward()
- SendToServer(LTG, "Digging", LTG)
- TurnRight()
- SendToServer(LTG, "Digging", LTG)
- TurnRight()
- DigForward()
- SendToServer(LTG, "Digging", LTG)
- TurnLeft()
- DigUp()
- Turtle.Suck.Up()
- Up()
- SendToServer(LTG, "Digging", LTG)
- TurnLeft()
- DigForward()
- SendToServer(LTG, "Digging", LTG)
- TurnRight()
- SendToServer(LTG, "Digging", LTG)
- TurnRight()
- DigForward()
- SendToServer(LTG, "Digging", LTG)
- TurnLeft()
- DigUp()
- Turtle.Suck.Up()
- Up()
- SendToServer(LTG, "Digging", LTG)
- TurnLeft()
- DigForward()
- SendToServer(LTG, "Digging", LTG)
- TurnRight()
- SendToServer(LTG, "Digging", LTG)
- TurnRight()
- DigForward()
- SendToServer(LTG, "Digging", LTG)
- TurnLeft()
- Down()
- Turtle.Suck.Down()
- SendToServer(LTG, "Digging", LTG)
- Down()
- Turtle.Suck.Down()
- SendToServer(LTG, "Digging", LTG)
- TurnLeft()
- Turtle.Suck.Forward()
- SendToServer(LTG, "Digging", LTG)
- TurnRight()
- TurnRight()
- Turtle.Suck.Forward()
- SendToServer(LTG, "Digging", LTG)
- TurnLeft()
- SendToServer(LTG, "Digging", LTG)
- end
- System.setComputerLabel(Turtle.System.TurtleName) -- Turtle name
- SendToServer("Done", LTG)
- GoTo(QuarryX, QuarryY, QuarryZ)
- GoHome()
- EmptyInventory()
- PutToolAway()
- end
- -- Tree Farm
- -- Tree Farm Head
- function TreeFarm(Farm)
- Screen.clear()
- printCentered(math.floor(h/2), "Tree farm")
- System.setComputerLabel(Turtle.System.TurtleName.."Tree Farm") -- Turtle name
- Turtle.Slot.Select(1)
- GetTool(Tool.Axe)
- local DAta = {Name = "TreeFarm", X = Farm.X, Y = Farm.Y, Z = Farm.Z}
- SafeLog(DAta)
- Screen.clear()
- printCentered(math.floor(h/2), "Going To TreeFarm")
- GoTo(Farm.X, Turtle.Data.Height.Travel, Farm.Z)
- GoTo(Farm.X, Farm.Y, Farm.Z)
- TurnDirection(1)
- local Sapling = 16
- local BoneMeal = {}
- BoneMeal[1] = 15
- BoneMeal[2] = 14
- BoneMeal[3] = 13
- BoneMeal[4] = 12
- BoneMeal[5] = 11
- BoneMeal[6] = 10
- BoneMeal[7] = 9
- local A = 1
- local SaveSlots = {}
- SaveSlots[1] = 1
- SaveSlots[2] = 2
- SaveSlots[3] = 3
- SaveSlots[4] = 4
- SaveSlots[5] = 5
- SaveSlots[6] = 6
- SaveSlots[7] = 7
- SaveSlots[8] = 8
- local B = 1
- local Status = true
- local NumberA = 0
- while Status do
- local n = Turtle.Slot.Item.Count(Sapling)
- if not(n) then
- n = 0
- end
- Screen.clear()
- printCentered(math.floor(h/2), "Done: "..tostring(NumberA))
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local OldFuel = Turtle.Data.FuelLevel
- for i = 1, 16, 1 do
- Turtle.Slot.Select(i)
- Turtle.Fuel.ReFuel()
- end
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel == OldFuel or Turtle.Data.FuelLevel < MinFuel then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- SendToServer("Low Fuel", n)
- if Turtle.Data.Cor.X ~= Turtle.Data.Home.X or Turtle.Data.Cor.Y ~= Turtle.Data.Home.Y or Turtle.Data.Cor.Z ~= Turtle.Data.Home.Z then
- GoHome()
- end
- EmptyInventory()
- ReFuel()
- SendToServer("GoTo", n)
- GoTo(SX, TravelHeight, SZ)
- SendToServer("GoTo", n)
- GoTo(SX, SY, SZ)
- SendToServer("GoTo", n)
- TurnDirection(SR)
- end
- end
- n = Turtle.Slot.Item.Count(Sapling)
- if not(n) then
- n = 0
- end
- SendToServer("Check Stuff", n)
- if n < 1 then
- SendToServer("No saplings", n)
- Status = false
- break
- end
- n = Turtle.Slot.Item.Count(Sapling)
- if not(n) then
- n = 0
- end
- if Turtle.Slot.Item.Count(SaveSlots[8]) > 0 then
- local SX, SY, SZ, SR = Turtle.Data.Cor.X, Turtle.Data.Cor.Y, Turtle.Data.Cor.Z, Turtle.Data.Cor.R
- GoTo(Turtle.Data.Home.X, Turtle.Data.Height.Travel, Turtle.Data.Home.Z)
- GoTo(Turtle.Data.Home.X, Turtle.Data.Home.Y, Turtle.Data.Home.Z)
- TurnDirection(Turtle.Data.Home.R)
- for i = 1, #SaveSlots do
- Turtle.Slot.Select(SaveSlots[i])
- Turtle.Drop.Down()
- end
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- SendToServer("Planting", n)
- for i = 1, 5 do
- TurnLeft()
- Turtle.Slot.Select(Sapling)
- local Placed = Turtle.Place.Forward()
- if Placed then
- NumberA = NumberA + 1
- end
- TurnRight()
- if i < 5 then
- for I = 1, 7 do
- n = Turtle.Slot.Item.Count(Sapling)
- if not(n) then
- n = 0
- end
- SendToServer("Planting", n)
- Forward()
- end
- end
- end
- GoTo(Farm.X, Farm.Y, Farm.Z)
- TurnDirection(1)
- n = Turtle.Slot.Item.Count(Sapling)
- if not(n) then
- n = 0
- end
- SendToServer("Bonemeal", n)
- local Tree = {}
- for i = 1, 5 do
- TurnLeft()
- Tree[i] = false
- local Succes, Table = Turtle.Inspect.Forward()
- if Succes then
- if string.find(Table.name, "sapling") then
- while not(Tree[i]) do
- if Turtle.Slot.Item.Count(BoneMeal[A]) == 0 then
- if A < 7 then
- A = A + 1
- else
- Screen.setCursorPos(1, 2)
- SendToServer("No bonemeal", n)
- write("No BoneMeal! Fill Slots 9 till 15 and press key:")
- local Event, Key, isHeld = System.pullEvent("key")
- A = 1
- end
- end
- SendToServer("Bonemeal", n)
- Turtle.Slot.Select(BoneMeal[A])
- Turtle.Place.Forward()
- local Succes, Table = Turtle.Inspect.Forward()
- if Succes then
- if string.find(Table.name, "log") then
- Tree[i] = true
- end
- end
- end
- end
- end
- TurnRight()
- if i < 5 then
- for I = 1, 7 do
- SendToServer("Bonemeal", n)
- Forward()
- end
- end
- end
- Turtle.Slot.Select(SaveSlots[B])
- SendToServer("Chopping", n)
- GoTo(Farm.X, Farm.Y, Farm.Z)
- TurnDirection(1)
- for i = 1, 5 do
- SendToServer("Chopping", n)
- TurnLeft()
- local Succes, Data = Turtle.Inspect.Forward()
- if Succes then
- DigForward()
- Forward()
- local c = 0
- for a = 1, 15 do
- SendToServer("Chopping", n)
- local Succes1, Data1 = Turtle.Inspect.Up()
- if not(Succes1) then
- break
- end
- DigUp()
- Up()
- SendToServer("Chopping", n)
- c = c + 1
- if not(string.find(Data.name, "spruce")) and not(string.find(Data.name, "birch")) then
- Temp.Start = {}
- Temp.Start.R = Turtle.Data.Cor.R
- Temp.Start.X = Turtle.Data.Cor.X
- Temp.Start.Z = Turtle.Data.Cor.Z
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- TurnLeft()
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- Forward()
- SendToServer("Chopping", n)
- DigForward()
- GoTo(Temp.Start.X, Turtle.Data.Cor.Y, Temp.Start.Z)
- TurnDirection(Temp.Start.R)
- SendToServer("Chopping", n)
- end
- end
- for b = 1, c do
- SendToServer("Chopping", n)
- Down()
- end
- Back()
- end
- SendToServer("Chopping", n)
- TurnRight()
- if i < 5 then
- for I = 1, 7 do
- SendToServer("Chopping", n)
- Forward()
- end
- end
- end
- GoTo(Farm.X, Farm.Y, Farm.Z)
- TurnDirection(1)
- SendToServer("Timer", n)
- Screen.clear()
- printCentered(math.floor(h/2), "Done: "..tostring(NumberA))
- Screen.setCursorPos(1, h)
- SetColors(Color.White, Color.Black)
- Screen.write("Press A key to stop in 5 sec.: ")
- SetColors(Color.Black, Color.White)
- local TimerA = System.startTimer(5)
- local Event, Key, isHeld = "nil", "nil", "nil"
- while Event ~= "timer" do
- Event, Key, isHeld = System.pullEvent()
- if Event == "key" then
- Status = false
- end
- end
- end
- Screen.clear()
- printCentered(math.floor(h/2), "Going Home")
- GoHome()
- EmptyInventory()
- PutToolAway()
- System.setComputerLabel(Turtle.System.TurtleName) -- Turtle name
- end
- -- Tree Farm Sub's
- function LoadTreeFarm()
- local Doto = {What = "Command", Command = "/L04DTR33F4RM/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Doto))
- local Event, Part1, Id, RId, Message = System.pullEvent("modem_message")
- if Message ~= nil then
- Turtle.Data.Farms.TreeFarms = UnPack(Message)
- end
- end
- function SaveTreeFarm()
- local Data = {What = "Command", Command = "/S4V3TR33F4RM/", Data = Turtle.Data.Farms.TreeFarms}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Data))
- end
- -- Farm
- -- Farm Head
- function MakeFarm(Option1, Option2, Slots)
- Screen.clear()
- printCentered(math.floor(h/2), "Make Land")
- System.setComputerLabel(Turtle.System.TurtleName.."Make Farm") -- Turtle name
- SendToServer("MakeFarm", 0)
- local DAta
- if Option1 == "Nether" then
- Temp.X = Option2[2]
- Temp.Z = Option2[1]
- DAta = {Name = "NMakeFarm", X = Turtle.Data.Quarry.X, Y = Turtle.Data.Quarry.Y + 1, Z = Turtle.Data.Quarry.Z, Length = Option2[2] - 1, Lines = Option2[1]}
- elseif Option1 == "Normale" then
- if Option2 == FarmLand["one"] then
- Temp.X = #Option2
- Temp.Z = #Option2[1]
- Temp.HowMany = Temp.X
- elseif Option2 == FarmLand["two"] or Option2 == FarmLand["three"] then
- Temp.X = Temp.HowMany
- Temp.Z = #Option2[1]
- end
- DAta = {Name = "MakeFarm", X = Turtle.Data.Quarry.X, Y = Turtle.Data.Quarry.Y + 1, Z = Turtle.Data.Quarry.Z, Length = Temp.Z, Lines = Temp.X}
- end
- SafeLog(DAta)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Height.Travel, Turtle.Data.Quarry.Z)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- local SaveData = {
- Cor = {
- X = Turtle.Data.Quarry.X,
- Y = Turtle.Data.Quarry.Y + 1,
- Z = Turtle.Data.Quarry.Z,
- R = Turtle.Data.Cor.R},
- What = Option1,
- Size = {
- X = Temp.X,
- Z = Temp.Z - 1}}
- LoadLand()
- if Option1 == "Nether" then
- table.insert(Turtle.Data.Farms.Normale.Nether, SaveData)
- elseif Option1 == "Normale" then
- table.insert(Turtle.Data.Farms.Normale.Overworld, SaveData)
- end
- SaveLand(SaveData)
- if Option1 == "Nether" then
- Slots.SaveSlots = 5
- local A = 1
- for c = 1, #Option2[2] do
- for b = 1, (#Option2[1] - 1) do
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local OldFuel = Turtle.Data.FuelLevel
- ReFuel()
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel == OldFuel or Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- if Turtle.Data.Cor.X ~= Turtle.Data.Home.X or Turtle.Data.Cor.Y ~= Turtle.Data.Home.Y or Turtle.Data.Cor.Z ~= Turtle.Data.Home.Z then
- GoHome()
- end
- ReFuel()
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- local Succes, Table = Turtle.Inspect.Down()
- if Turtle.Slot.Item.Count(A) == 0 then
- A = A + 1
- if A > #Slots.SoulSand then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- GoHome()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- SendToServer("No Sand", 0)
- write("Fill slots 1-4 with Soul Sand and press enter ...")
- read()
- A = 1
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- if Succes then
- if Table.name ~= Blocks.SoulSand then
- SendToServer("MakeFarm N", 0)
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots.SoulSand[A])
- Turtle.Place.Down()
- end
- else
- SendToServer("MakeFarm N", 0)
- Turtle.Slot.Select(Slots.SoulSand[A])
- Turtle.Place.Down()
- end
- Forward()
- SendToServer("MakeFarm N", 0)
- end
- local Succes, Table = Turtle.Inspect.Down()
- if Succes then
- if Table.name ~= Blocks.SoulSand then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots.SoulSand[A])
- Turtle.Place.Down()
- end
- else
- Turtle.Slot.Select(Slots.SoulSand[A])
- Turtle.Place.Down()
- end
- if (c%2) == 1 and c < Option2[1] then
- TurnRight()
- Forward()
- TurnRight()
- elseif c < Option2[1] then
- TurnLeft()
- Forward()
- TurnLeft()
- end
- SendToServer("MakeFarm N", 0)
- end
- elseif Option1 == "Normale" then
- if Option2 == FarmLand["one"] then
- Slots.SaveSlots = 9
- local A = 1
- for c = 1, #Option2 do
- for b = 1, (#Option2[c] - 1) do
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local OldFuel = Turtle.Data.FuelLevel
- ReFuel()
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel == OldFuel or Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- if Turtle.Data.Cor.X ~= Turtle.Data.Home.X or Turtle.Data.Cor.Y ~= Turtle.Data.Home.Y or Turtle.Data.Cor.Z ~= Turtle.Data.Home.Z then
- GoHome()
- end
- ReFuel()
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- local Succes, Table = Turtle.Inspect.Down()
- if Turtle.Slot.Item.Count(A) == 0 then
- A = A + 1
- if A > #Slots[Blocks.Dirt] then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- GoHome()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- SendToServer("No dirt", 0)
- write("Fill slots 1-4 with Dirt and press enter ...")
- read()
- A = 1
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- if Succes then
- if Table.name ~= Blocks.Water and c == 5 and b == 5 then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots[Blocks.Water])
- Turtle.Place.Down()
- elseif Table.name ~= Blocks.Dirt and Table.name ~= Blocks.Grass then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots[Option2[c][b]][A])
- Turtle.Place.Down()
- end
- else
- if c == 5 and b == 5 then
- Turtle.Slot.Select(Slots[Blocks.Water])
- Turtle.Place.Down()
- else
- Turtle.Slot.Select(Slots[Option2[c][b]][A])
- Turtle.Place.Down()
- end
- end
- Forward()
- SendToServer("MakeFarm", 0)
- end
- local Succes, Table = Turtle.Inspect.Down()
- if Succes then
- if Table.name ~= Blocks.Water and c == 5 and b == 5 then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots[Blocks.Water])
- Turtle.Place.Down()
- elseif Table.name ~= Blocks.Dirt and Table.name ~= Blocks.Grass then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots[Option2[c][#Option2[c]]][A])
- Turtle.Place.Down()
- end
- else
- if c == 5 and b == 5 then
- Turtle.Slot.Select(Slots[Blocks.Water])
- Turtle.Place.Down()
- else
- Turtle.Slot.Select(Slots[Option2[c][#Option2[c]]][A])
- Turtle.Place.Down()
- end
- end
- if (c%2) == 1 and c < #Option2 then
- TurnRight()
- Forward()
- TurnRight()
- elseif c < #Option2 then
- TurnLeft()
- Forward()
- TurnLeft()
- end
- SendToServer("MakeFarm", 0)
- end
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y + 1, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- Turtle.Slot.Select(Slots.Hoe)
- Turtle.Equip.Left()
- for c = 1, #Option2 do
- for b = 1, (#Option2[c] - 1) do
- SendToServer("MakeFarm", 0)
- Turtle.Dig.Down()
- Forward()
- end
- Turtle.Dig.Down()
- if (c%2) == 1 and c < #Option2 then
- TurnRight()
- Forward()
- TurnRight()
- elseif c < #Option2 then
- TurnLeft()
- Forward()
- TurnLeft()
- end
- SendToServer("MakeFarm", 0)
- end
- Turtle.Slot.Select(Slots.Hoe)
- Turtle.Equip.Left()
- elseif Option2 == FarmLand["two"] then
- Slots.SaveSlots = 9
- local A = 1
- MakeWater(Option2, Slots)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- GetWater(Option2, Slots)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- for c = 1, Temp.HowMany do
- for b = 1, (#Option2[1] - 1) do
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local OldFuel = Turtle.Data.FuelLevel
- ReFuel()
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel == OldFuel or Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- if Turtle.Data.Cor.X ~= Turtle.Data.Home.X or Turtle.Data.Cor.Y ~= Turtle.Data.Home.Y or Turtle.Data.Cor.Z ~= Turtle.Data.Home.Z then
- GoHome()
- end
- ReFuel()
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- local Succes, Table = Turtle.Inspect.Down()
- if Turtle.Slot.Item.Count(A) == 0 then
- A = A + 1
- if A > #Slots[Blocks.Dirt] then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- GoHome()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- SendToServer("No dirt", 0)
- write("Fill slots 1-4 with Dirt and press enter ...")
- read()
- A = 1
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- local Succes, Table = Turtle.Inspect.Down()
- if Succes then
- if Table.name ~= Blocks.Water and b == 1 then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots[Blocks.Water[1]])
- Turtle.Place.Down()
- elseif Table.name ~= Blocks.Dirt and Table.name ~= Blocks.Grass then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots[Blocks.Dirt[A]])
- Turtle.Place.Down()
- end
- else
- if b == 1 then
- Turtle.Slot.Select(Slots[Blocks.Water[1]])
- Turtle.Place.Down()
- else
- Turtle.Slot.Select(Slots[Blocks.Dirt[A]])
- Turtle.Place.Down()
- end
- end
- Forward()
- SendToServer("MakeFarm", 0)
- end
- local Succes, Table = Turtle.Inspect.Down()
- if Succes then
- if Table.name ~= Blocks.Water then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots[Blocks.Water[2]])
- Turtle.Place.Down()
- end
- else
- Turtle.Slot.Select(Slots[Blocks.Water[2]])
- Turtle.Place.Down()
- end
- if (c%2) == 1 and c < Temp.HowMany then
- TurnRight()
- Forward()
- TurnRight()
- elseif c < Temp.HowMany then
- TurnLeft()
- Forward()
- TurnLeft()
- end
- local SX, SY, SZ, SR = Turtle.Data.Cor.X, Turtle.Data.Cor.Y, Turtle.Data.Cor.Z, Turtle.Data.Cor.R
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- GetWater(Option2, Slots)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- SendToServer("MakeFarm", 0)
- end
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y + 1, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- Turtle.Slot.Select(Slots.Hoe)
- Turtle.Equip.Left()
- for c = 1, Temp.HowMany do
- for b = 1, (#Option2[1] - 1) do
- SendToServer("MakeFarm", 0)
- Turtle.Dig.Down()
- Forward()
- end
- Turtle.Dig.Down()
- if (c%2) == 1 and c < Temp.HowMany then
- TurnRight()
- Forward()
- TurnRight()
- elseif c < Temp.HowMany then
- TurnLeft()
- Forward()
- TurnLeft()
- end
- SendToServer("MakeFarm", 0)
- end
- Turtle.Slot.Select(Slots.Hoe)
- Turtle.Equip.Left()
- elseif Option2 == FarmLand["three"] then
- Slots.SaveSlots = 9
- local A = 1
- local B = 1
- MakeWater(Slots)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- GetWater(Slots)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- for c = 1, Temp.HowMany do
- for b = 1, (#Option2 - 1) do
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local OldFuel = Turtle.Data.FuelLevel
- ReFuel()
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel == OldFuel or Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- if Turtle.Data.Cor.X ~= Turtle.Data.Home.X or Turtle.Data.Cor.Y ~= Turtle.Data.Home.Y or Turtle.Data.Cor.Z ~= Turtle.Data.Home.Z then
- GoHome()
- end
- ReFuel()
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- local Succes, Table = Turtle.Inspect.Down()
- if Turtle.Slot.Item.Count(A) == 0 then
- A = A + 1
- if A > #Slots[Blocks.Dirt] then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- GoHome()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- SendToServer("No dirt", 0)
- write("Fill slots 1-4 with Dirt and press enter ...")
- read()
- A = 1
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- local Succes, Table = Turtle.Inspect.Down()
- if Succes then
- if Table.name ~= Blocks.Water and b == 5 then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots[Blocks.Water[B]])
- Turtle.Place.Down()
- B = B + 1
- if B >= 3 then
- B = 1
- end
- elseif Table.name ~= Blocks.Dirt and Table.name ~= Blocks.Grass then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots[Blocks.Dirt[A]])
- Turtle.Place.Down()
- end
- else
- if b == 5 then
- Turtle.Slot.Select(Slots[Blocks.Water[B]])
- Turtle.Place.Down()
- B = B + 1
- if B >= 3 then
- B = 1
- end
- else
- Turtle.Slot.Select(Slots[Blocks.Dirt[A]])
- Turtle.Place.Down()
- end
- end
- Forward()
- SendToServer("MakeFarm", 0)
- end
- local Succes, Table = Turtle.Inspect.Down()
- if Succes then
- if Table.name ~= Blocks.Dirt and Table.name ~= Blocks.Grass then
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots[Blocks.Dirt[A]])
- Turtle.Place.Down()
- end
- else
- Turtle.Slot.Select(Slots[Blocks.Dirt[A]])
- Turtle.Place.Down()
- end
- if (c%2) == 1 and c < Temp.HowMany then
- TurnRight()
- Forward()
- TurnRight()
- elseif c < Temp.HowMany then
- local SX, SY, SZ, SR = Turtle.Data.Cor.X, Turtle.Data.Cor.Y, Turtle.Data.Cor.Z, Turtle.Data.Cor.R
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- GetWater(Option2, Slots)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- TurnLeft()
- Forward()
- TurnLeft()
- end
- SendToServer("MakeFarm", 0)
- end
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y + 1, Turtle.Data.Quarry.Z)
- TurnDirection(1)
- Turtle.Slot.Select(Slots.Hoe)
- Turtle.Equip.Left()
- for c = 1, Temp.HowMany do
- for b = 1, (#Option2 - 1) do
- SendToServer("MakeFarm", 0)
- Turtle.Dig.Down()
- Forward()
- end
- Turtle.Dig.Down()
- if (c%2) == 1 and c < Temp.HowMany then
- TurnRight()
- Forward()
- TurnRight()
- elseif c < Temp.HowMany then
- TurnLeft()
- Forward()
- TurnLeft()
- end
- SendToServer("MakeFarm", 0)
- end
- Turtle.Slot.Select(Slots.Hoe)
- Turtle.Equip.Left()
- end
- end
- GoHome()
- System.setComputerLabel(Turtle.System.TurtleName) -- Turtle name
- end
- function PlowLand(Farm)
- Screen.clear()
- printCentered(math.floor(h/2), "Plowing")
- System.setComputerLabel(Turtle.System.TurtleName.."Farm Plow") -- Turtle name
- SendToServer("Plow", 0)
- local DAta = {Name = "Plow", X = Farm.Cor.X, Y = Farm.Cor.Y, Z = Farm.Cor.Z, Length = Farm.Size.Z, Lines = Farm.Size.X}
- SafeLog(DAta)
- GetTool(Tool.Hoe)
- GoTo(Farm.Cor.X, Turtle.Data.Height.Travel, Farm.Cor.Z)
- GoTo(Farm.Cor.X, Farm.Cor.Y, Farm.Cor.Z)
- TurnDirection(Farm.Cor.R)
- local GotIt = false
- for c = 1, Farm.Size.X do
- for b = 1, Farm.Size.Z do
- GotIt = false
- local Succes, Data = Turtle.Inspect.Down()
- if Succes then
- for What, Tbl in pairs(Plant) do
- if Data.name == Tbl.name then
- GotIt = true
- end
- end
- end
- SendToServer("Plow", 0)
- if GotIt == false then
- Turtle.Dig.Down()
- Turtle.Dig.Down()
- end
- Forward()
- end
- GotIt = false
- local Succes, Data = Turtle.Inspect.Down()
- if Succes then
- for What, Tbl in pairs(Plant) do
- if Data.name == Tbl.name then
- GotIt = true
- end
- end
- end
- if GotIt == false then
- Turtle.Dig.Down()
- Turtle.Dig.Down()
- end
- if (c%2) == 1 and c < Farm.Size.X then
- TurnRight()
- Forward()
- TurnRight()
- elseif c < Farm.Size.X then
- TurnLeft()
- Forward()
- TurnLeft()
- end
- SendToServer("Plow", 0)
- end
- GoHome()
- EmptyInventory()
- PutToolAway()
- System.setComputerLabel(Turtle.System.TurtleName) -- Turtle name
- end
- function PlantSeeds(Farm)
- Screen.clear()
- printCentered(math.floor(h/2), "Seeding")
- System.setComputerLabel(Turtle.System.TurtleName.."Farm Plan") -- Turtle name
- SendToServer("Plant", 0)
- local DAta = {Name = "Seed", X = Farm.Cor.X, Y = Farm.Cor.Y, Z = Farm.Cor.Z, Length = Farm.Size.Z, Lines = Farm.Size.X}
- SafeLog(DAta)
- local Succes = false
- local i = 1
- Turtle.Slot.Select(i)
- local Succes = getOutInventory(Temp.Plant.seed)
- if Succes then
- Turtle.Slot.Select(1)
- Turtle.TransferTo(13)
- Turtle.Slot.Select(2)
- Turtle.TransferTo(14)
- Turtle.Slot.Select(3)
- Turtle.TransferTo(15)
- Turtle.Slot.Select(4)
- Turtle.TransferTo(16)
- end
- for i = 1, 12 do
- Turtle.Drop.Down()
- end
- while not(Succes) do
- Screen.clear()
- Screen.setCursorPos(1, 1)
- SendToServer("No Seed", 0)
- print("No seed found!!! Give seed in slot 13-16: "..Temp.Plant.seed)
- print("Then press enter. ")
- read()
- local Info = Turtle.Slot.Item.Detail(13)
- if Info.name == Temp.Plant.seed then
- Succes = true
- end
- end
- GoTo(Farm.Cor.X, Turtle.Data.Height.Travel, Farm.Cor.Z)
- GoTo(Farm.Cor.X, Farm.Cor.Y, Farm.Cor.Z)
- TurnDirection(Farm.Cor.R)
- local A = 13
- for c = 1, Farm.Size.X do
- for b = 1, Farm.Size.Z do
- Turtle.Slot.Select(A)
- while Turtle.Slot.Item.Count(A) == 0 do
- A = A + 1
- if A > 16 then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- GoHome()
- A = 13
- local Succes = getOutInventory(Temp.Plant.seed)
- if Succes then
- Turtle.Slot.Select(1)
- Turtle.TransferTo(13)
- Turtle.Slot.Select(2)
- Turtle.TransferTo(14)
- Turtle.Slot.Select(3)
- Turtle.TransferTo(15)
- Turtle.Slot.Select(4)
- Turtle.TransferTo(16)
- end
- for i = 1, 12 do
- Turtle.Drop.Down()
- end
- while not(Succes) do
- Screen.clear()
- Screen.setCursorPos(1, 1)
- SendToServer("No Seed", 0)
- print("No seed found!!! Give seed in slot 13-16: "..Temp.Plant.seed)
- print("Then press enter. ")
- read()
- local Info = Turtle.Slot.Item.Detail(13)
- if Info.name == Temp.Plant.seed then
- Succes = true
- end
- end
- A = 13
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- Turtle.Slot.Select(A)
- SendToServer("Plant", 0)
- Turtle.Place.Down()
- Forward()
- end
- Turtle.Slot.Select(A)
- while Turtle.Slot.Item.Count(A) == 0 do
- A = A + 1
- if A > 16 then
- local SX = Turtle.Data.Cor.X
- local SY = Turtle.Data.Cor.Y
- local SZ = Turtle.Data.Cor.Z
- local SR = Turtle.Data.Cor.R
- GoHome()
- A = 13
- local Succes = getOutInventory(Temp.Plant.seed)
- if Succes then
- Turtle.Slot.Select(1)
- Turtle.TransferTo(13)
- Turtle.Slot.Select(2)
- Turtle.TransferTo(14)
- Turtle.Slot.Select(3)
- Turtle.TransferTo(15)
- Turtle.Slot.Select(4)
- Turtle.TransferTo(16)
- end
- for i = 1, 12 do
- Turtle.Drop.Down()
- end
- while not(Succes) do
- Screen.clear()
- Screen.setCursorPos(1, 1)
- SendToServer("No Seed", 0)
- print("No seed found!!! Give seed in slot 13-16: "..Temp.Plant.seed)
- print("Then press enter. ")
- read()
- local Info = Turtle.Slot.Item.Detail(13)
- if Info.name == Temp.Plant.seed then
- Succes = true
- end
- end
- A = 13
- GoTo(SX, Turtle.Data.Height.Travel, SZ)
- GoTo(SX, SY, SZ)
- TurnDirection(SR)
- end
- end
- Turtle.Slot.Select(A)
- Turtle.Place.Down()
- if (c%2) == 1 and c < Farm.Size.X then
- TurnRight()
- Forward()
- TurnRight()
- elseif c < Farm.Size.X then
- TurnLeft()
- Forward()
- TurnLeft()
- end
- SendToServer("Plant", 0)
- end
- GoHome()
- EmptyInventory()
- Turtle.Slot.Select(1)
- System.setComputerLabel(Turtle.System.TurtleName) -- Turtle name
- end
- function HarvestLand(Farm)
- Screen.clear()
- printCentered(math.floor(h/2), "Harvesting")
- System.setComputerLabel(Turtle.System.TurtleName.."Farm Har") -- Turtle name
- SendToServer("Harvets", 0)
- local DAta = {Name = "Harvest", X = Farm.Cor.X, Y = Farm.Cor.Y, Z = Farm.Cor.Z, Length = Farm.Size.Z, Lines = Farm.Size.X}
- SafeLog(DAta)
- GetTool(Tool.Hoe)
- GoTo(Farm.Cor.X, Turtle.Data.Height.Travel, Farm.Cor.Z)
- GoTo(Farm.Cor.X, Farm.Cor.Y, Farm.Cor.Z)
- TurnDirection(Farm.Cor.R)
- for c = 1, Farm.Size.X do
- for b = 1, Farm.Size.Z do
- local Succes, Data = Turtle.Inspect.Down()
- if Succes then
- for What, Tbl in pairs(Plant) do
- if Data.name == Tbl.name and Data.state.age == Tbl.age then
- Temp.Tamp = Tbl
- Turtle.Dig.Down()
- end
- end
- end
- Forward()
- SendToServer("Harvets", 0)
- end
- local Succes, Data = Turtle.Inspect.Down()
- if Succes then
- for What, Tbl in pairs(Plant) do
- if Data.name == Tbl.name and Data.state.age == Tbl.age then
- Temp.Tamp = Tbl
- Turtle.Dig.Down()
- end
- end
- end
- if (c%2) == 1 and c < Farm.Size.X then
- TurnRight()
- Forward()
- TurnRight()
- elseif c < Farm.Size.X then
- TurnLeft()
- Forward()
- TurnLeft()
- end
- SendToServer("Harvets", 0)
- end
- GoHome()
- EmptyInventory()
- PutToolAway()
- System.setComputerLabel(Turtle.System.TurtleName) -- Turtle name
- end
- function Farm()
- Screen.clear()
- printCentered(math.floor(h/2), "Farming")
- if Turtle.Data.Cor.X ~= Turtle.Data.Home.X or Turtle.Data.Cor.Y ~= Turtle.Data.Home.Y or Turtle.Data.Cor.Z ~= Turtle.Data.Home.Z then
- GoHome()
- EmptyInventory()
- PutToolAway()
- Turtle.Data.FuelLevel = GetFuel()
- if Turtle.Data.FuelLevel < Turtle.Fuel.MinFuel then
- local OldFuel = Turtle.Data.FuelLevel
- ReFuel()
- end
- end
- LoadLand()
- System.setComputerLabel(Turtle.System.TurtleName.."Farming") -- Turtle name
- SendToServer("Farming", 0)
- Temp.Plant = nil
- local Farms = Turtle.Data.Farms.Normale.Overworld
- for i = 1, #Farms do
- SendToServer("Farming", 0)
- ReFuel()
- SendToServer("Farming", 0)
- HarvestLand(Farms[i])
- SendToServer("Farming", 0)
- ReFuel()
- SendToServer("Farming", 0)
- PlowLand(Farms[i])
- SendToServer("Farming", 0)
- ReFuel()
- Temp.Plant = Temp.Tamp
- SendToServer("Farming", 0)
- PlantSeeds(Farms[i])
- end
- local NetherFarms = Turtle.Data.Farms.Normale.Nether
- for i = 1, #NetherFarms do
- SendToServer("Farming", 0)
- ReFuel()
- SendToServer("Farming", 0)
- HarvestLand(NetherFarms[i])
- SendToServer("Farming", 0)
- ReFuel()
- SendToServer("Farming", 0)
- Temp.Plant = Plant.Wart
- PlantSeeds(NetherFarms[i])
- end
- SendToServer("Farming", 0)
- System.setComputerLabel(Turtle.System.TurtleName) -- Turtle name
- end
- -- Farm Sub's
- function LoadLand()
- local Doto = {What = "Command", Command = "/L04DL4ND/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Doto))
- local Event, Part1, Id, RId, Message = System.pullEvent("modem_message")
- if Message ~= nil then
- Turtle.Data.Farms.Normale.Overworld = UnPack(Message)
- end
- local Event, Part1, Id, RId, Message = System.pullEvent("modem_message")
- if Message ~= nil then
- Turtle.Data.Farms.Normale.Nether = UnPack(Message)
- end
- end
- function SaveLand(SaveData)
- local Data = {What = "Command", Command = "/S4V3L4ND/", Data = SaveData}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Data))
- end
- function MakeWater(Option2, Slots)
- if Option2 == FarmLand["two"] then
- TurnRight()
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots.Water[1])
- Turtle.Place.Down()
- Forward()
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Forward()
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots.Water[2])
- Turtle.Place.Down()
- elseif Option2 == FarmLand["three"] then
- for i = 1, 4 do
- Forward()
- end
- TurnRight()
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots.Water[1])
- Turtle.Place.Down()
- Forward()
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Forward()
- Turtle.Slot.Select(Slots.SaveSlots)
- Turtle.Dig.Down()
- Turtle.Slot.Select(Slots.Water[2])
- Turtle.Place.Down()
- end
- end
- function GetWater(Option2, Slots)
- if Option2 == FarmLand["two"] then
- TurnRight()
- Forward()
- Turtle.Slot.Select(Slots.Water[1])
- Turtle.Place.Down()
- sleep(1)
- Turtle.Slot.Select(Slots.Water[2])
- Turtle.Place.Down()
- elseif Option2 == FarmLand["three"] then
- for i = 1, 4 do
- Forward()
- end
- TurnRight()
- Forward()
- Turtle.Slot.Select(Slots.Water[1])
- Turtle.Place.Down()
- sleep(1)
- Turtle.Slot.Select(Slots.Water[2])
- Turtle.Place.Down()
- end
- end
- -- Program Starts Here, First Do Function Startup()
- Startup()
- local a = Turtle.Data.Farms.Normale.Overworld
- local b = Turtle.Data.Farms.Normale.Nether
- local MaxPlowOptions = #a
- local MaxNetherOptions = #b
- local MaxHarvestOptions = #a + #b
- -- Set Colors
- SetColors(Color.Black, Color.White)
- -- clear terminal screen
- Screen.clear()
- -- Set Cursor Position
- Screen.setCursorPos(1, 1)
- -- Start Loop, if Turtle.System.PowerOn == false then script stops and it go to command shell (Dos)
- while Turtle.System.PowerOn do
- Turtle.Data.FuelLevel = GetFuel()
- local Data = {What = "Command", Command = "/FR33/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Data))
- checkPers()
- LoadBlackListedDigging()
- SendToServer("Waiting Orders", 0)
- drawHeadMenu()
- drawHeadFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- Data = {What = "Command", Command = "/W0RK1NG/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Data))
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nHeadOption > 1 then
- nHeadOption = nHeadOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nHeadOption < MaxHeadOptions then
- nHeadOption = nHeadOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nHeadOption == 1 then
- -- Info Menu
- local GoBack = false
- nInfoOption = 1
- while not(GoBack) do
- drawInfoMenu()
- SendToServer("Waiting Orders", 0)
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 or p1 == keys.pageUp then
- if nInfoOption < MaxInfoOptions then
- nInfoOption = nInfoOption + 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 or p1 == keys.pageDown then
- if nInfoOption > 1 then
- nInfoOption = nInfoOption - 1
- end
- elseif p1 == keys.b then
- GoBack = true
- end
- end
- end
- elseif nHeadOption == 2 then
- -- System Menu
- local GoBack = false
- nSystemOption = 1
- while not(GoBack) do
- drawSystemMenu()
- drawSystemFrontend()
- SendToServer("Waiting Orders", 0)
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nSystemOption > 1 then
- nSystemOption = nSystemOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nSystemOption < MaxSystemOptions then
- nSystemOption = nSystemOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nSystemOption == 1 then
- if Turtle.System.GroupState == false then
- Modem.open(Turtle.System.Modem.SharedID)
- Turtle.System.GroupState = true
- elseif Turtle.System.GroupState == true then
- Modem.close(Turtle.System.Modem.SharedID)
- Turtle.System.GroupState = false
- end
- elseif nSystemOption == 2 then
- ReFuel()
- elseif nSystemOption == 3 then
- local GoSlotSelectBack = false
- nSlotSelectOption = 1
- while not(GoSlotSelectBack) do
- drawSlotSelectFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nSlotSelectOption > 1 then
- nSlotSelectOption = nSlotSelectOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nSlotSelectOption < MaxSlotSelectOptions then
- nSlotSelectOption = nSlotSelectOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nSlotSelectOption == 1 then
- local S = Turtle.Slot.Selected()
- if S < 16 then
- S = S + 1
- Turtle.Slot.Select(S)
- end
- elseif nSlotSelectOption == 2 then
- local S = Turtle.Slot.Selected()
- if S > 1 then
- S = S - 1
- Turtle.Slot.Select(S)
- end
- end
- elseif p1 == keys.b then
- GoSlotSelectBack = true
- end
- end
- end
- elseif nSystemOption == 4 then
- local GoEquipBack = false
- nEquipOption = 1
- while not(GoEquipBack) do
- drawEquipFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nEquipOption > 1 then
- nEquipOption = nEquipOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nEquipOption < MaxEquipOptions then
- nEquipOption = nEquipOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nEquipOption == 1 then
- Turtle.Equip.Left()
- GoEquipBack = true
- elseif nEquipOption == 2 then
- Turtle.Equip.Right()
- GoEquipBack = true
- end
- elseif p1 == keys.b then
- GoEquipBack = true
- end
- end
- end
- elseif nSystemOption == 5 then
- local N = 0
- repeat
- Screen.clear()
- Screen.setCursorPos(1, h/2)
- Screen.write("Slot Number 1/16: ")
- N = tonumber(read())
- until N >= 1 and N <= 16
- Turtle.TransferTo(N)
- elseif nSystemOption == 6 then
- turtle.craft()
- elseif nSystemOption == 7 then
- local GoDetectBack = false
- nDetectOption = 1
- while not(GoDetectBack) do
- drawDetectFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nDetectOption > 1 then
- nDetectOption = nDetectOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nDetectOption < MaxDetectOptions then
- nDetectOption = nDetectOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nDetectOption == 1 then
- Turtle.Detect.State = tostring(Turtle.Detect.Forward())
- GoDetectBack = true
- elseif nDetectOption == 2 then
- Turtle.Detect.State = tostring(Turtle.Detect.Up())
- GoDetectBack = true
- elseif nDetectOption == 3 then
- Turtle.Detect.State = tostring(Turtle.Detect.Down())
- GoDetectBack = true
- end
- elseif p1 == keys.b then
- GoDetectBack = true
- end
- end
- end
- elseif nSystemOption == 8 then
- local GoInspectBack = false
- nInspectOption = 1
- while not(GoInspectBack) do
- drawInspectFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nInspectOption > 1 then
- nInspectOption = nInspectOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nInspectOption < MaxInspectOptions then
- nInspectOption = nInspectOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nInspectOption == 1 then
- local GoInspectInfoBack = false
- while not(GoInspectInfoBack) do
- local Succes, Data = Turtle.Inspect.Forward()
- drawInspectInfoFrontend(Succes, Data)
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.enter or p1 == keys.numPadEnter or p1 == keys.b then
- GoInspectInfoBack = true
- end
- end
- end
- GoInspectBack = true
- elseif nInspectOption == 2 then
- local GoInspectInfoBack = false
- while not(GoInspectInfoBack) do
- local Succes, Data = Turtle.Inspect.Up()
- drawInspectInfoFrontend(Succes, Data)
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.enter or p1 == keys.numPadEnter or p1 == keys.b then
- GoInspectInfoBack = true
- end
- end
- end
- GoInspectBack = true
- elseif nInspectOption == 3 then
- local GoInspectInfoBack = false
- while not(GoInspectInfoBack) do
- local Succes, Data = Turtle.Inspect.Down()
- drawInspectInfoFrontend(Succes, Data)
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.enter or p1 == keys.numPadEnter or p1 == keys.b then
- GoInspectInfoBack = true
- end
- end
- end
- GoInspectBack = true
- end
- elseif p1 == keys.b then
- GoInspectBack = true
- end
- end
- end
- elseif nSystemOption == 9 then
- local GoCompareBack = false
- nCompareOption = 1
- while not(GoCompareBack) do
- drawCompareFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nCompareOption > 1 then
- nCompareOption = nCompareOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nCompareOption < MaxCompareOptions then
- nCompareOption = nCompareOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nCompareOption == 1 then
- Turtle.Compare.State = tostring(Turtle.Compare.Forward())
- GoCompareBack = true
- elseif nCompareOption == 2 then
- Turtle.Compare.State = tostring(Turtle.Compare.Up())
- GoCompareBack = true
- elseif nCompareOption == 3 then
- Turtle.Compare.State = tostring(Turtle.Compare.Down())
- GoCompareBack = true
- end
- elseif p1 == keys.b then
- GoCompareBack = true
- end
- end
- end
- elseif nSystemOption == 10 then
- Screen.clear()
- PrintLog()
- elseif nSystemOption == 11 then
- SafeSettings()
- System.reboot()
- elseif nSystemOption == 12 then
- Screen.clear()
- printCentered(math.floor(h/2), "Reset Turtle? ... Y/N")
- local Event, p1, p2, p3 = System.pullEvent("key")
- if p1 == keys.y then
- local File = fs.exists("/OS/.Data/.Settings.set")
- if File then
- fs.delete("/OS/.Data/.Settings.set")
- System.reboot()
- end
- end
- elseif nSystemOption == 13 then
- Screen.clear()
- local pressedkey = false
- local What
- while not(pressedkey) do
- printCentered(math.floor(h/2), "1 = Vanilla, 2 = Mods")
- local Event, p1, p2, p3 = System.pullEvent("key")
- if p1 == keys.one or p1 == keys.numPad1 then
- What = "Vanlla"
- pressedkey = true
- elseif p1 == keys.two or p1 == keys.numPad2 then
- What = "Mods"
- pressedkey = true
- end
- end
- printCentered(math.floor(h/2), "Name : ")
- local name = string.lower(read())
- table.insert(BlackListedDigging[What], name)
- SafeBlackListedDigging()
- elseif nSystemOption == 14 then
- Screen.clear()
- printCentered(math.floor(h/2), "Run Uninstaller? ... Y/N")
- local Event, p1, p2, p3 = System.pullEvent("key")
- if p1 == keys.y then
- shell.run("/OS/Unintall.lua")
- end
- elseif nSystemOption == 15 then
- elseif nSystemOption == 16 then
- end
- elseif p1 == keys.b then
- GoBack = true
- end
- end
- end
- elseif nHeadOption == 3 then
- -- Movements Menu
- local GoBack = false
- nMovementsOption = 1
- MovementPage = 1
- while not(GoBack) do
- drawMovementsMenu()
- drawMovementsFrontend()
- SendToServer("Waiting Orders", 0)
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nMovementsOption > 1 then
- nMovementsOption = nMovementsOption - 1
- MovementPage = math.ceil(nMovementsOption/8)
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nMovementsOption < MaxMovementsOptions then
- nMovementsOption = nMovementsOption + 1
- MovementPage = math.ceil(nMovementsOption/8)
- end
- elseif p1 == keys.pageDown then
- if MovementPage > 1 then
- MovementPage = MovementPage - 1
- nMovementsOption = nMovementsOption - 8
- end
- elseif p1 == keys.pageUp then
- if MovementPage < MaxMovementPage then
- MovementPage = MovementPage + 1
- nMovementsOption = nMovementsOption + 8
- if nMovementsOption > MaxMovementsOptions then
- nMovementsOption = MaxMovementsOptions
- end
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nMovementsOption == 1 then
- --Attack
- local GoAttackBack = false
- nAttackOption = 1
- while not(GoAttackBack) do
- drawAttackFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nAttackOption > 1 then
- nAttackOption = nAttackOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nAttackOption < MaxAttackOptions then
- nAttackOption = nAttackOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nAttackOption == 1 then
- Turtle.Attack.Forward()
- GoAttackBack = true
- elseif nAttackOption == 2 then
- Turtle.Attack.Up()
- GoAttackBack = true
- elseif nAttackOption == 3 then
- Turtle.Attack.Down()
- GoAttackBack = true
- end
- elseif p1 == keys.b then
- GoAttackBack = true
- end
- end
- end
- elseif nMovementsOption == 2 then
- --Dig
- local GoDigBack = false
- nDigOption = 1
- while not(GoDigBack) do
- drawDigFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nDigOption > 1 then
- nDigOption = nDigOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nDigOption < MaxDigOptions then
- nDigOption = nDigOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nDigOption == 1 then
- Turtle.Dig.Forward()
- GoDigBack = true
- elseif nDigOption == 2 then
- Turtle.Dig.Up()
- GoDigBack = true
- elseif nDigOption == 3 then
- Turtle.Dig.Down()
- GoDigBack = true
- end
- elseif p1 == keys.b then
- GoDigBack = true
- end
- end
- end
- elseif nMovementsOption == 3 then
- --Suck
- local GoSuckBack = false
- nSuckOption = 1
- while not(GoSuckBack) do
- drawSuckFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nSuckOption > 1 then
- nSuckOption = nSuckOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nSuckOption < MaxSuckOptions then
- nSuckOption = nSuckOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nSuckOption == 1 then
- Turtle.Suck.Forward()
- GoSuckBack = true
- elseif nSuckOption == 2 then
- Turtle.Suck.Up()
- GoSuckBack = true
- elseif nSuckOption == 3 then
- Turtle.Suck.Down()
- GoSuckBack = true
- end
- elseif p1 == keys.b then
- GoSuckBack = true
- end
- end
- end
- elseif nMovementsOption == 4 then
- --Drop
- local GoDropBack = false
- nDropOption = 1
- while not(GoDropBack) do
- drawDropFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nDropOption > 1 then
- nDropOption = nDropOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nDropOption < MaxDropOptions then
- nDropOption = nDropOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nDropOption == 1 then
- Turtle.Drop.Forward()
- GoDropBack = true
- elseif nDropOption == 2 then
- Turtle.Drop.Up()
- GoDropBack = true
- elseif nDropOption == 3 then
- Turtle.Drop.Down()
- GoDropBack = true
- end
- elseif p1 == keys.b then
- GoDropBack = true
- end
- end
- end
- elseif nMovementsOption == 5 then
- --Place
- local GoPlaceBack = false
- nPlaceOption = 1
- while not(GoPlaceBack) do
- drawPlaceFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nPlaceOption > 1 then
- nPlaceOption = nPlaceOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nPlaceOption < MaxPlaceOptions then
- nPlaceOption = nPlaceOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nPlaceOption == 1 then
- Turtle.Place.Forward()
- GoPlaceBack = true
- elseif nPlaceOption == 2 then
- Turtle.Place.Up()
- GoPlaceBack = true
- elseif nPlaceOption == 3 then
- Turtle.Place.Down()
- GoPlaceBack = true
- end
- elseif p1 == keys.b then
- GoPlaceBack = true
- end
- end
- end
- elseif nMovementsOption == 6 then
- Screen.clear()
- printCentered(math.floor(h/2), "X Cor: ")
- Turtle.Data.Quarry.X = tonumber(read())
- printCentered(math.floor(h/2), "Y Cor: ")
- Turtle.Data.Quarry.Y = tonumber(read())
- printCentered(math.floor(h/2), "Z Cor: ")
- Turtle.Data.Quarry.Z = tonumber(read())
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Height.Travel, Turtle.Data.Quarry.Z)
- GoTo(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z)
- elseif nMovementsOption == 7 then
- GoHome()
- elseif nMovementsOption == 8 then
- Screen.clear()
- printCentered(math.floor(h/2), "1 = North, 2 = East, 3 = South, 4 = West: ")
- Turtle.Data.Quarry.R = tonumber(read())
- TurnDirection(Turtle.Data.Quarry.R)
- elseif nMovementsOption == 9 then
- EmptyInventory()
- end
- elseif p1 == keys.w then
- Button.flash("W")
- Forward()
- elseif p1 == keys.s then
- Button.flash("S")
- Back()
- elseif p1 == keys.a then
- Button.flash("A")
- TurnLeft()
- elseif p1 == keys.d then
- Button.flash("D")
- TurnRight()
- elseif p1 == keys.r then
- Button.flash("R")
- Up()
- elseif p1 == keys.f then
- Button.flash("F")
- Down()
- elseif p1 == keys.b then
- GoBack = true
- end
- elseif Event == "mouse_click" then
- local Butt, MX, MY = p1, p2, p3
- Button.checkxy(MX,MY)
- end
- end
- elseif nHeadOption == 4 then
- -- Progs Menu
- local GoBack = false
- nProgramsOption = 1
- while not(GoBack) do
- drawProgramsMenu()
- drawProgramsFrontend()
- SendToServer("Waiting Orders", 0)
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nProgramsOption > 1 then
- nProgramsOption = nProgramsOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nProgramsOption < MaxProgramsOptions then
- nProgramsOption = nProgramsOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nProgramsOption == 1 then
- -- Quarry
- Screen.clear()
- printCentered(math.floor(h/2), "Give in X Cordinates: ")
- Turtle.Data.Quarry.X = tonumber(io.read())
- printCentered(math.floor(h/2), "Give in Y Cordinates: ")
- Turtle.Data.Quarry.Y = tonumber(io.read())
- printCentered(math.floor(h/2), "Give in Z Cordinates: ")
- Turtle.Data.Quarry.Z = tonumber(io.read())
- if Turtle.Data.Quarry.Y == 0 then
- Turtle.Data.Quarry.X = Turtle.Data.Cor.X
- Turtle.Data.Quarry.Y = Turtle.Data.Cor.Y
- Turtle.Data.Quarry.Z = Turtle.Data.Cor.Z
- end
- printCentered(math.floor(h/2), "Blocks (front): ")
- Turtle.Data.Quarry.Blocks = tonumber(io.read())
- Turtle.Data.Quarry.Blocks = Turtle.Data.Quarry.Blocks - 1
- printCentered(math.floor(h/2), "Lines (side): ")
- Turtle.Data.Quarry.Lines = tonumber(io.read())
- printCentered(math.floor(h/2), "Layers: ")
- Turtle.Data.Quarry.Layers = tonumber(io.read())
- if Turtle.Data.Quarry.Layers == 0 then
- Turtle.Data.Quarry.Layers = 250
- end
- DigQuarry(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z, Turtle.Data.Quarry.Blocks, Turtle.Data.Quarry.Lines, Turtle.Data.Quarry.Layers)
- Turtle.Data.Quarry.X = 0
- Turtle.Data.Quarry.Y = 0
- Turtle.Data.Quarry.Z = 0
- Turtle.Data.Quarry.Blocks = 0
- Turtle.Data.Quarry.Lines = 0
- Turtle.Data.Quarry.Layers = 0
- elseif nProgramsOption == 2 then
- -- Tunnel 3X3
- Screen.clear()
- printCentered(math.floor(h/2), "Give in X Cordinates: ")
- Turtle.Data.Quarry.X = tonumber(io.read())
- printCentered(math.floor(h/2), "Give in Y Cordinates: ")
- Turtle.Data.Quarry.Y = tonumber(io.read())
- printCentered(math.floor(h/2), "Give in Z Cordinates: ")
- Turtle.Data.Quarry.Z = tonumber(io.read())
- if Turtle.Data.Quarry.Y == 0 then
- Turtle.Data.Quarry.X = Turtle.Data.Cor.X
- Turtle.Data.Quarry.Y = Turtle.Data.Cor.Y
- Turtle.Data.Quarry.Z = Turtle.Data.Cor.Z
- end
- printCentered(math.floor(h/2), "Look at 1 = North, 2 = East, 3 = South, 4 = West: ")
- Turtle.Data.Quarry.R = tonumber(io.read())
- printCentered(math.floor(h/2), "Blocks (front): ")
- Turtle.Data.Quarry.Blocks = tonumber(io.read())
- DigTunnel3BY3(Turtle.Data.Quarry.X, Turtle.Data.Quarry.Y, Turtle.Data.Quarry.Z, Turtle.Data.Quarry.R, Turtle.Data.Quarry.Blocks)
- Turtle.Data.Quarry.X = 0
- Turtle.Data.Quarry.Y = 0
- Turtle.Data.Quarry.Z = 0
- Turtle.Data.Quarry.R = 1
- Turtle.Data.Quarry.Blocks = 0
- elseif nProgramsOption == 3 then
- -- Tree Farm
- if not(Turtle.System.Nether) then
- local GoTreeFarmBack = false
- nTreeFarmOption = 1
- while not(GoTreeFarmBack) do
- drawTreeFarmMenu()
- drawTreeFarmFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nTreeFarmOption > 1 then
- nTreeFarmOption = nTreeFarmOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nTreeFarmOption < MaxTreeFarmOptions then
- nTreeFarmOption = nTreeFarmOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nTreeFarmOption == 1 then
- Screen.clear()
- printCentered(math.floor(h/2), "Give in X Cordinates: ")
- local TargetX = tonumber(io.read())
- printCentered(math.floor(h/2), "Give in Y Cordinates: ")
- local TargetY = tonumber(io.read())
- printCentered(math.floor(h/2), "Give in Z Cordinates: ")
- local TargetZ = tonumber(io.read())
- local Data = {X = TargetX, Y = TargetY, Z = TargetZ}
- if Turtle.Data.Farms.TreeFarms == nil then
- Turtle.Data.Farms.TreeFarms = {}
- end
- table.insert(Turtle.Data.Farms.TreeFarms, Data)
- SaveTreeFarm()
- elseif nTreeFarmOption == 2 then
- LoadTreeFarm()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- print("What Farm:")
- Screen.setCursorPos(1, 3)
- if Turtle.Data.Farms.TreeFarms then
- for i = 1, #Turtle.Data.Farms.TreeFarms do
- print(i.." = Farm"..i.." Cor: X: "..Turtle.Data.Farms.TreeFarms[i].X.." Y: "..Turtle.Data.Farms.TreeFarms[i].Y.." Z: "..Turtle.Data.Farms.TreeFarms[i].Z)
- end
- local Number = tonumber(read())
- Screen.clear()
- Screen.setCursorPos(1, 1)
- print("Slot 16 = Saplings, slots 9-15 = bonemeal, slots 1-8 = saved for pick up.")
- print("Put item in slots and a key: ")
- local Event, p1, p2 = System.pullEvent("key")
- TreeFarm(Turtle.Data.Farms.TreeFarms[Number])
- end
- end
- elseif p1 == keys.b then
- GoTreeFarmBack = true
- end
- end
- end
- end
- elseif nProgramsOption == 4 then
- -- Farm
- if not(Turtle.System.Nether) then
- local GoFarmBack = false
- nFarmOption = 1
- while not(GoFarmBack) do
- drawFarmMenu()
- drawFarmFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nFarmOption > 1 then
- nFarmOption = nFarmOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nFarmOption < MaxFarmOptions then
- nFarmOption = nFarmOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nFarmOption == 1 then
- local GoWhatLandBack = false
- nWhatLandOption = 1
- while not(GoWhatLandBack) do
- drawWhatLandMenu()
- drawWhatLandFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if p1 == keys.up or p1 == keys.numPad8 then
- if nWhatLandOption > 1 then
- nWhatLandOption = nWhatLandOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nWhatLandOption < MaxWhatLandOptions then
- nWhatLandOption = nWhatLandOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nWhatLandOption == 1 then
- local GoMakeNormaleFarmLandsBack = false
- nMakeNormaleFarmLandsOption = 1
- while not(GoMakeNormaleFarmLandsBack) do
- drawMakeNormaleFarmLandsMenu()
- drawMakeNormaleFarmLandsFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if p1 == keys.up or p1 == keys.numPad8 then
- if nMakeNormaleFarmLandsOption > 1 then
- nMakeNormaleFarmLandsOption = nMakeNormaleFarmLandsOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nMakeNormaleFarmLandsOption < MaxMakeNormaleFarmLandsOptions then
- nMakeNormaleFarmLandsOption = nMakeNormaleFarmLandsOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- Turtle.Data.Quarry.Farm = {}
- Screen.clear()
- printCentered(math.floor(h/2),"Give in X Cordinates: ")
- Turtle.Data.Quarry.X = tonumber(io.read())
- printCentered(math.floor(h/2),"Give in Y Cordinates: ")
- Turtle.Data.Quarry.Y = tonumber(io.read())
- printCentered(math.floor(h/2),"Give in Z Cordinates: ")
- Turtle.Data.Quarry.Z = tonumber(io.read())
- if Turtle.Data.Quarry.Y == 0 then
- Turtle.Data.Quarry.X = Turtle.Data.Cor.X
- Turtle.Data.Quarry.Y = Turtle.Data.Cor.Y
- Turtle.Data.Quarry.Z = Turtle.Data.Cor.Z
- end
- GetTool(Tool.PickAxe)
- local Slots = {}
- if nMakeNormaleFarmLandsOption == 1 then
- Turtle.Data.Quarry.Farm.Land = FarmLand["one"]
- Slots[Blocks.Dirt] = {}
- Slots[Blocks.Dirt][1] = 1
- Slots[Blocks.Dirt][2] = 2
- Slots[Blocks.Dirt][3] = 3
- Slots[Blocks.Dirt][4] = 4
- Slots[Blocks.Water] = 5
- Slots.Hoe = 6
- Screen.clear()
- printCentered(math.floor(h/2) -1, "Put in slot 1-4 dirt")
- printCentered(math.floor(h/2) +0, "and in slot 5 water,")
- printCentered(math.floor(h/2) +1, "and in slot 6 a Diamond Hoe")
- printCentered(math.floor(h/2) +2, "and press any key ...")
- elseif nMakeNormaleFarmLandsOption == 2 then
- Turtle.Data.Quarry.Farm.Land = FarmLand["two"]
- Slots[Blocks.Dirt] = {}
- Slots[Blocks.Dirt][1] = 1
- Slots[Blocks.Dirt][2] = 2
- Slots[Blocks.Dirt][3] = 3
- Slots[Blocks.Dirt][4] = 4
- Slots[Blocks.Water] = {}
- Slots[Blocks.Water][1] = 5
- Slots[Blocks.Water][2] = 6
- Slots.Hoe = 7
- Screen.clear()
- printCentered(math.floor(h/2) -1, "Put in slot 1-4 dirt")
- printCentered(math.floor(h/2) +0, "and in slot 5-6 water,")
- printCentered(math.floor(h/2) +1, "and in slot 7 a Diamond Hoe")
- printCentered(math.floor(h/2) +2, "and press any key ...")
- elseif nMakeNormaleFarmLandsOption == 3 then
- Turtle.Data.Quarry.Farm.Land = FarmLand["three"]
- Slots[Blocks.Dirt] = {}
- Slots[Blocks.Dirt][1] = 1
- Slots[Blocks.Dirt][2] = 2
- Slots[Blocks.Dirt][3] = 3
- Slots[Blocks.Dirt][4] = 4
- Slots[Blocks.Water] = {}
- Slots[Blocks.Water][1] = 5
- Slots[Blocks.Water][2] = 6
- Slots.Hoe = 7
- Screen.clear()
- printCentered(math.floor(h/2) -1, "Put in slot 1-4 dirt")
- printCentered(math.floor(h/2) +0, "and in slot 5-6 water,")
- printCentered(math.floor(h/2) +1, "and in slot 7 a Diamond Hoe")
- printCentered(math.floor(h/2) +2, "and press any key ...")
- end
- local Event, p1, p2, p3 = System.pullEvent("key")
- MakeFarm("Normale", Turtle.Data.Quarry.Farm.Land, Slots)
- EmptyInventory()
- PutToolAway()
- GoMakeNormaleFarmLandsBack = true
- elseif p1 == keys.b then
- GoMakeNormaleFarmLandsBack = true
- end
- end
- GoWhatLandBack = true
- elseif nWhatLandOption == 2 then
- local N = {}
- Screen.clear()
- printCentered(math.floor(h/2) -1,"How big u want to be ur farm?")
- Screen.setCursorPos(1, 7)
- printCentered(math.floor(h/2) +0,"How many blocks on the X (E/W): ")
- N[2] = tonumber(read())
- printCentered(math.floor(h/2) +1,"How many blocks on the Z (N/S): ")
- N[1] = tonumber(read())
- printCentered(math.floor(h/2),"Give in X Cordinates: ")
- Turtle.Data.Quarry.X = tonumber(io.read())
- printCentered(math.floor(h/2),"Give in Y Cordinates: ")
- Turtle.Data.Quarry.Y = tonumber(io.read())
- printCentered(math.floor(h/2),"Give in Z Cordinates: ")
- Turtle.Data.Quarry.Z = tonumber(io.read())
- GetTool(Tool.PickAxe)
- local Slots = {}
- Slots.SoulSand = {}
- Slots.SoulSand[1] = 1
- Slots.SoulSand[2] = 2
- Slots.SoulSand[3] = 3
- Slots.SoulSand[4] = 4
- Screen.clear()
- printCentered(math.floor(h/2),"Put in slot 1-4 Soul Sand and press any key ...")
- local Event, p1, p2, p3 = System.pullEvent("key")
- MakeFarm("Nether", N, Slots)
- EmptyInventory()
- PutToolAway()
- GoWhatLandBack = true
- end
- elseif p1 == keys.b then
- GoWhatLandBack = true
- end
- end
- elseif nFarmOption == 2 then
- local GoFarmingBack = false
- nFarmFarmingOption = 1
- while not(GoFarmingBack) do
- drawFarmFarmingMenu()
- drawFarmFarmingFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if p1 == keys.up or p1 == keys.numPad8 then
- if nFarmFarmingOption > 1 then
- nFarmFarmingOption = nFarmFarmingOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nFarmFarmingOption < MaxFarmFarmingOptions then
- nFarmFarmingOption = nFarmFarmingOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nFarmFarmingOption == 1 then
- -- Do All
- Farm()
- elseif nFarmFarmingOption == 2 then
- -- Plow
- local GoPlowBack = false
- nPlowOption = 1
- while not(GoPlowBack) do
- Screen.clear()
- drawPlowFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if p1 == keys.up or p1 == keys.numPad8 then
- if nPlowOption > 1 then
- nPlowOption = nPlowOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nPlowOption < MaxPlowOptions then
- nPlowOption = nPlowOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- PlowLand(Turtle.Data.Farm.Normale.Overworld[nPlowOption])
- GoPlowBack = true
- elseif p1 == keys.b then
- GoPlowBack = true
- end
- end
- elseif nFarmFarmingOption == 3 then
- -- Plant Seeds
- local GoPlantBack = false
- nPlantOption = 1
- Screen.clear()
- while not(GoPlantBack) do
- drawPlantMenu()
- drawPlantFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if p1 == keys.up or p1 == keys.numPad8 then
- if nPlantOption > 1 then
- nPlantOption = nPlantOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nPlantOption < MaxPlantOptions then
- nPlantOption = nPlantOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nPlantOption == 1 then
- Temp.Plant = Plant.Wheat
- Temp.name = "Wheat"
- elseif nPlantOption == 2 then
- Temp.Plant = Plant.Beetroot
- Temp.name = "Beetroot"
- elseif nPlantOption == 3 then
- Temp.Plant = Plant.Carrot
- Temp.name = "Carrot"
- elseif nPlantOption == 4 then
- Temp.Plant = Plant.Potato
- Temp.name = "Potato"
- elseif nPlantOption == 5 then
- Temp.Plant = Plant.Wart
- Temp.name = "Wart"
- end
- if Temp.Plant == Plant.Wart then
- local GoNetherBack = false
- nNetherOption = 1
- Screen.clear()
- while not(GoNetherBack) do
- drawNetherFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if p1 == keys.up or p1 == keys.numPad8 then
- if nNetherOption > 1 then
- nNetherOption = nNetherOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nNetherOption < MaxNetherOptions then
- nNetherOption = nNetherOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- PlantSeeds(Turtle.Data.Farms.Normale.Nether[nNetherOption])
- GoNetherBack = true
- elseif p1 == keys.b then
- GoNetherBack = true
- end
- end
- else
- local GoPlowBack = false
- nPlowOption = 1
- Screen.clear()
- while not(GoPlowBack) do
- drawPlowFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if p1 == keys.up or p1 == keys.numPad8 then
- if nPlowOption > 1 then
- nPlowOption = nPlowOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nPlowOption < MaxPlowOptions then
- nPlowOption = nPlowOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- PlantSeeds(Turtle.Data.Farms.Normale.Overworld[nPlowOption])
- GoPlowBack = true
- elseif p1 == keys.b then
- GoPlowBack = true
- end
- end
- end
- GoPlantBack = true
- elseif p1 == keys.b then
- GoPlantBack = true
- end
- end
- elseif nFarmFarmingOption == 4 then
- -- Harvest
- local GoHarvestBack = false
- nHarvestOption = 1
- Screen.clear()
- while not(GoHarvestBack) do
- drawHarvestFrontend()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- sleep(0.5)
- if p1 == keys.up or p1 == keys.numPad8 then
- if nHarvestOption > 1 then
- nHarvestOption = nHarvestOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nHarvestOption < MaxHarvestOptions then
- nHarvestOption = nHarvestOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- local n = Turtle.Data.Farms.Normale.Overworld
- local B = #n
- if nHarvestOption <= B then
- HarvestLand(Turtle.Data.Farms.Normale.Overworld[nHarvestOption])
- else
- HarvestLand(Turtle.Data.Farms.Normale.Nether[nHarvestOption])
- end
- GoHarvestBack = true
- elseif p1 == keys.b then
- GoHarvestBack = true
- end
- end
- end
- elseif p1 == keys.b then
- GoFarmingBack = true
- end
- end
- end
- elseif p1 == keys.b then
- GoFarmBack = true
- end
- end
- end
- end
- -- elseif nProgramsOption == 5 then
- -- 3D Paint and Build
- -- local Data = {What = "Command", Command = "/3DPaintPro/"}
- -- shell.run("/Progs/3DPrint.lua")
- end
- elseif p1 == keys.b then
- GoBack = true
- end
- end
- end
- elseif nHeadOption == 5 then
- elseif nHeadOption == 6 then
- elseif nHeadOption == 7 then
- elseif nHeadOption == 8 then
- elseif nHeadOption == 9 then
- elseif nHeadOption == 10 then
- elseif nHeadOption == 11 then
- elseif nHeadOption == 12 then
- elseif nHeadOption == 13 then
- elseif nHeadOption == 14 then
- elseif nHeadOption == 15 then
- elseif nHeadOption == 16 then
- end
- elseif p1 == keys.q then
- SafeSettings()
- SafeBlackListedDigging()
- local Data = {What = "Command", Command = "/CH3CK0UT/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Data))
- System.shutdown()
- elseif p1 == keys.slash then
- SafeSettings()
- SafeBlackListedDigging()
- local Data = {What = "Command", Command = "/CH3CK0UT/"}
- Send(Turtle.System.Modem.ServerID, Turtle.System.Modem.OwnID, Pack(Data))
- System.pullEvent = OldpullEvent
- SetColors(Color.Black, Color.White)
- Screen.clear()
- Screen.setCursorPos(1, 1)
- Turtle.System.PowerOn = false
- end
- elseif Event == "modem_message" then
- onMessage(UnPack(p4), p3)
- end
- end
Add Comment
Please, Sign In to add comment