Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------
- --Select a slot
- -------------------------------
- function ss(num)
- turtle.select(num)
- end
- -------------------------------
- --Turning Functions
- -------------------------------
- --Turn Right
- function tr(num)
- if (num == nil or num == '') then
- num = 1
- end
- for i=1,num,1 do
- turtle.turnRight()
- end
- end
- --Turn Left
- function tl(num)
- if (num == nil or num == '') then
- num = 1
- end
- for i=1,num,1 do
- turtle.turnLeft()
- end
- end
- -------------------------------
- --Movement Functions
- -------------------------------
- --Go forward
- function gf(num)
- if (num == nil or num == '') then
- num = 1
- end
- for i=1,num,1 do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- end
- end
- --Go Back
- function gb(num)
- if (num == nil or num == '') then
- num = 1
- end
- for i=1,num,1 do
- turtle.back()
- end
- end
- --Go Up
- function gu(num)
- if (num == nil or num == '') then
- num = 1
- end
- for i=1,num,1 do
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.up()
- end
- end
- --Go Down
- function gd(num)
- if (num == nil or num == '') then
- num = 1
- end
- for i=1,num,1 do
- if turtle.detectDown() then
- turtle.digDown()
- turtle.down()
- else
- turtle.down()
- end
- end
- end
- -------------------------------
- --Digging Functions
- -------------------------------
- -- Dig Forward
- function df()
- while turtle.detect() do
- turtle.dig()
- end
- end
- --Dig Up
- function du()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- --Dig Down
- function dd()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- -------------------------------
- --Placing Functions
- -------------------------------
- --Place Forward
- function pf(num)
- if (num == nil or num == '') then
- turtle.place()
- else
- ss(num)
- turtle.place()
- end
- end
- --Place Up
- function pu(num)
- if (num == nil or num == '') then
- turtle.placeUp()
- else
- ss(num)
- turtle.placeUp()
- end
- end
- --Place Down
- function pd(num)
- if (num == nil or num == '') then
- turtle.placeDown()
- else
- ss(num)
- turtle.placeDown()
- end
- end
- -------------------------------
- --Refuels the turtle
- -------------------------------
- function refuel(num)
- if (num == nil or num == '') then
- turtle.refuel()
- else
- ss(num)
- turtle.refuel()
- end
- end
- -------------------------------
- --Checks the fuel levels
- -------------------------------
- function fuelCheck()
- x = 1
- while x==1 do
- refuel(16)
- y=turtle.getFuelLevel()
- print("Fuel level is: ", tostring(y))
- if y > 500 then
- x=2
- else
- print("Add more fuel to slot 16 to continue.")
- os.sleep(120)
- x=1
- end
- end
- end --fuelCheck()
- -------------------------------
- --Unload all extra stuff into the chest beneath turtle
- -------------------------------
- function unloadTurtle()
- print("Unloading Inventory...")
- for i=1,12
- do
- turtle.select(i)
- turtle.dropDown()
- end
- end --unloadTurtle
- -------------------------------
- --Craft Sugar from Sugar Cane
- -------------------------------
- function craftSugar()
- ss(1)
- turtle.suckDown(4)
- turtle.craft()
- turtle.transferTo(sugar,4)
- ss(1)
- end --craftSugar
- -------------------------------
- --Harvest Sugar Cane
- -------------------------------
- function harvestSugarCane()
- gu(2)
- gf(8)
- tr(2)
- gd()
- gf(8)
- tr(2)
- gd()
- unloadTurtle()
- end --harvestSugarCane
- -------------------------------
- --Harvest Pumpkin
- -------------------------------
- function harvestPumpkins()
- -- Go to pumpkins
- --Harvest them
- ss(1)
- --go to pumpkin chest
- turtle.drop()
- ss(pumpkins)
- turtle.suck(4)
- ss(1)
- end --harvestPumpkins
- -------------------------------
- --Harvest Eggs
- -------------------------------
- function harvestEggs()
- --go to egg chest
- --Get the eggs we need
- ss(1)
- turtle.drop()
- ss(eggs)
- turtle.suck(4)
- ss(1)
- end --harvestEggs
- -------------------------------
- --Craft Pumpkin Pie
- -------------------------------
- function craftPumpkinPie()
- turtle.craft
- ss(1)
- turtle.drop()
- ss(sugar)
- turtle.drop()
- ss(pumpkins)
- turtle.drop()
- ss(eggs)
- turtle.drop()
- --go back to starting position
- gd()
- gb(5)
- tl()
- gb()
- tl()
- gf()
- tr()
- end --craftPumpkinPie
- -------------------------------
- --Harvest the Supplies
- -------------------------------
- function harvestPPSupplies(i)
- ss(sugar)
- turtle.dropDown()
- ss(pumpkins)
- turtle.dropDown()
- ss(eggs)
- turtle.dropDown()
- harvestSugarCane()
- craftSugar()
- harvestPumkins()
- harvestEggs()
- craftPumpkinPie()
- end --harvestPPSupplies
- -------------------------------------------------------
- -------------------------------------------------------
- --These are the strings for the Initial print
- --Prints instructions for the User
- sugar, pumpkins, eggs = 13, 14, 15
- print("Please make sure slots 13, 14, and 15 are empty before we start.")
- io.write("You want me to harvest your Pumpkin Pie supplies for an hour? (y/n)")
- answer1=io.read()
- if answer1=="y" then
- i = 0
- while i < 13
- do
- fuelCheck()
- print("Starting program...")
- harvestPPSupplies(i)
- print("Done harvesting I will try again in 5 minutes.")
- i = i + 1
- if redstone.getInput("left") then
- i = 13
- else
- sleep(300)
- end
- end
- else
- print("I will wait here until you need me.")
- end
Add Comment
Please, Sign In to add comment