Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Initialize variables
- local xParkLocation = -1
- local xCoord = xParkLocation
- local yParkLocation = 0
- local yCoord = yParkLocation
- local xMinCoord = 0
- local xMaxCoord = 6
- local yMinCoord = 0
- local yMaxCoord = 6
- local xStart = xMinCoord --Set the starting X location equal to the min X coordinate
- local xLimit = xMaxCoord --Sets the ending X location equal to the max X coordinate
- local xDirection = 1 --1 goes forward and -1 goes backward
- local stuckTimer = 3 --Number of seconds to delay before retrying move
- --Create Fertilization function
- local function fertilize()
- --Loop through all Y coordinates
- for y = yMinCoord, yMaxCoord, 1 do
- --Loop through all X coordinates at the current Y coordinate
- for x = xStart, xLimit, xDirection do
- --Use BoneMeal
- turtle.select(9)
- turtle.placeDown()
- --Determine where the turtle should go based on its direction
- if xDirection == 1 then
- --Make sure the turtle doesn't go past the max X coordinate
- if x < xMaxCoord then
- --Move the turtle forward 1 block
- while turtle.forward() == false do
- print("Get out of my way!")
- sleep(stuckTimer)
- end
- --Update the X coordinate variable
- xCoord = xCoord + xDirection
- else
- --Make sure the turtle doesn't go past the max Y coordinate
- if yCoord < yMaxCoord then
- --Move to the next row
- turtle.turnLeft()
- while turtle.forward() == false do
- print("Get out of my way!")
- sleep(stuckTimer)
- end
- turtle.turnLeft()
- -- Set "for" loop variables
- --for next row
- xStart = xMaxCoord
- xLimit = xMinCoord
- xDirection = -1
- end
- end
- else
- --Make sure the turtle doesn't go past the min X coordinate
- if x > xMinCoord then
- --Move the turtle forward 1 block
- while turtle.forward() == false do
- print("Get out of my way!")
- sleep(stuckTimer)
- end
- xCoord = xCoord + xDirection
- else
- --Make sure the turtle doesn't go past the max Y coordinate
- if yCoord < yMaxCoord then
- --Move to next row
- turtle.turnRight()
- while turtle.forward() == false do
- print("Get out of my way!")
- sleep(stuckTimer)
- end
- turtle.turnRight()
- -- Set "for" loop variables
- --for next row
- xStart = xMinCoord
- xLimit = xMaxCoord
- xDirection = 1
- end
- end
- end
- end
- --Update the X coordinate variable
- if y < yMaxCoord then
- yCoord = yCoord + 1
- end
- end
- end
- --Create return to storage function
- local function returnToStorage()
- --Turn the turtle to face toward Y 0
- turtle.turnRight()
- --Move the turtle to Y 0
- for y = yCoord, yParkLocation, -1 do
- --Make sure the turtle doesn't go past the min Y coordinate
- if y > yMinCoord then
- --Move the turtle forward 1 block
- while turtle.forward() == false do
- print("Get out of my way!")
- sleep(stuckTimer)
- end
- end
- end
- --Turn the turtle to face toward X 0
- turtle.turnRight()
- --Move the turtle to X -1
- for x = xCoord, xParkLocation, -1 do
- --Make sure the turtle doesn't go past the X park coordinate
- if x >= xParkLocation then
- --Move the turtle back 1 block
- while turtle.forward() == false do
- print("Get out of my way!")
- sleep(stuckTimer)
- end
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- --Exit storage
- while turtle.forward() == false do
- print("Get out of my way!")
- sleep(stuckTimer)
- end
- --Select BoneMeal slot
- turtle.select(9)
- --Fertilize
- fertilize()
- --Return to storage
- returnToStorage()
- --Write to the console window
- print( "Fertilization Complete, Please add more Bonemeal" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement