Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- do_veggiesplant
- -----------------------------------------------------------------------
- --[[
- ("This program is currently intended for use with melon and pumpkin farms")
- ("The turtle must be placed with 1 empty block between the first possible farm item and the turtle")
- ("There must be a chest to the right of where the turtle is placed before starting the program to ensure correct dropoff")
- ("This program assumes a 4 wide system for Melons and Pumpkins, the length is variable:")
- ("D = Dirt(or other): W = Water: S = Seed: C = Chest: T = Turtle: M = Melon or Pumpkin Crop")
- (" W DDDDDDDDDDDD ")
- (" I DSSSSSSSSSSDC ")
- (" D DMMMMMMMMMM T ")
- (" T DMMMMMMMMMM ")
- (" H DSSSSSSSSSSD ")
- (" DWWWWWWWWWWD ")
- (" LENGTH ")
- --]]
- term.clear()
- term.setCursorPos(1, 1)
- minerID = os.getComputerID()
- turtleName = nil
- consoleID = 0
- version = "1.0"
- function getConsoleID()
- local fname = "ConsoleID"
- if fs.exists(fname) then
- file = fs.open(fname, "r")
- consoleID = tonumber(file.readAll())
- file.close()
- print("Monitor Console ID: "..consoleID)
- else
- updateStatus("Waiting for Console ID...",true)
- term.write("Monitor Console ID: ")
- consoleID = io.read()
- file = fs.open(fname, "w")
- file.write(consoleID)
- file.close()
- consoleID = tonumber(consoleID)
- end
- end
- function updateStatus(msg, silent)
- if not rednet.isOpen("right") then rednet.open("right") end
- if rednet.isOpen("right") then
- if turtleName == nil then return end
- networkmsg = "MM:"..turtleName..": "..msg
- if consoleID == 0 then
- rednet.broadcast(networkmsg)
- else
- rednet.send(consoleID,networkmsg)
- end
- end
- if not silent then print(msg) end
- end
- function getTurtleName()
- local fname = "TurtleName"
- if fs.exists(fname) then
- file = fs.open(fname, "r")
- turtleName = file.readAll()
- file.close()
- else
- term.write("Turtle Name: ")
- turtleName = io.read()
- file = fs.open(fname, "w")
- file.write(turtleName)
- file.close()
- end
- end
- -- Main Program
- updateStatus("Starting")
- term.clear()
- term.setCursorPos(1,1)
- getTurtleName()
- getConsoleID()
- function update()
- end
- function fuelItUp()
- updateStatus("...Working")
- --Finds out if the turtle needs to refuel and if it has fuel to run
- needsFuel = turtle.getFuelLevel()
- minimumFuelLevel = 10
- hasFuel = turtle.getItemCount(16)
- useFuel = turtle.refuel()
- if needsFuel == "unlimited" then
- else
- if tonumber(needsFuel) < tonumber(minimumFuelLevel) then
- if hasFuel > 0 then
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(1)
- else
- updateStatus("Please insert fuel into slot 16")
- repeat os.sleep(1)
- until tonumber(turtle.getItemCount(16)) > 0
- fuelItUp()
- end
- end
- end
- end
- function questions()
- print("How many blocks deep?")
- length = io.read()
- prime()
- end
- function prime()
- fuelItUp()
- hasSeeds = turtle.getItemCount(15)
- if tonumber(hasSeeds) > 0 then
- primePosition()
- else
- updateStatus("Please put Seeds into slot 15")
- os.sleep(5)
- prime()
- end
- end
- function primePosition()
- i = 0
- startBlock = 0
- totalPlanted = 0
- turtle.up()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- plantingDown()
- end
- function plantingDown()
- turtle.select(1)
- while i ~= tonumber(length) do
- fuelItUp()
- plantBot = turtle.detectDown()
- if plantBot == false then
- turtle.digDown()
- turtle.select(15)
- turtle.placeDown()
- totalPlanted = totalPlanted + 1
- end
- if turtle.getItemCount(14) > 0 then
- turtle.select(14)
- turtle.placeDown()
- end
- turtle.forward()
- i = i + 1
- end
- turn()
- end
- function turn()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- plantingBack()
- end
- function plantingBack()
- while i ~= startBlock do
- fuelItUp()
- plantBot = turtle.detectDown()
- if plantBot == false then
- turtle.digDown()
- turtle.select(15)
- turtle.placeDown()
- totalPlanted = totalPlanted + 1
- end
- if turtle.getItemCount(14) > 0 then
- turtle.select(14)
- turtle.placeDown()
- end
- turtle.forward()
- i = i - 1
- end
- finish()
- end
- function finish()
- updateStatus("Finished")
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.down()
- turtle.turnLeft()
- turtle.select(15)
- turtle.drop()
- turtle.select(14)
- turtle.drop()
- print("Total Plants Planted:")
- print(totalPlanted)
- updateStatus("Total Plants Planted: " ..totalPlanted)
- end
- questions()
- print("Press Enter to Continue")
- io.read()
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement