Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- print("X: "..tArgs[1].." Z: "..tArgs[2])
- --[1] is X, [2] is Z
- tArgs[1] = tonumber(tArgs[1]) --Changes tArgs[1] & [2] from a string to a number
- tArgs[2] = tonumber(tArgs[2])
- local success, data = turtle.inspect()
- local x = 0 --Counter for determining when to turn left / right depending on if this is odd or even
- function checkFuel()
- while turtle.getFuelLevel() < 1000 do
- for i = 1, 16 do -- loop through the slots
- turtle.select(i) -- change to the slot
- if turtle.refuel(0) then -- if it's valid fuel
- local halfStack = math.ceil(turtle.getItemCount(i)/2) -- work out half of the amount of fuel in the slot
- turtle.refuel(halfStack) -- consume half the stack as fuel
- end
- end
- end
- end
- function inspect()
- if turtle.inspectDown() then
- local success, data = turtle.inspectDown()
- if data and data.state.age == 7 then
- print("Crop ready.")
- print("Block name: ", data.name)
- print("Block metadata: ", data.state.age)
- turtle.digDown()
- turtle.suckDown()
- turtle.placeDown()
- end
- end
- turtle.forward()
- end
- function resetPos()
- --print("Resetting pos...")
- if tArgs[1] % 2 == 0 then
- --print("X is even. Straight path.")
- turtle.turnRight()
- for i = 1, tArgs[1] - 1 do
- turtle.forward()
- end
- else
- --print("X is odd. Following a corner path.")
- turtle.turnRight()
- turtle.turnRight()
- for i = 1, tArgs[2] - 1 do
- turtle.forward()
- end
- turtle.turnRight()
- for i = 1, tArgs[1] do
- turtle.forward()
- end
- end
- --print("Final right turn.")
- turtle.turnRight()
- end
- function turn()
- if x % 2 == 0 then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- --print("Switching Left")
- else
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- --print("Switching Right")
- end
- end
- --Main Code
- for u = 1, tArgs[1] do
- for y = 1, tArgs[2] do
- inspect()
- --print("Y: "..y)
- end
- --checkFuel()
- x = x + 1
- if x<tArgs[1] then
- turn()
- else
- --print("Not changing lanes.")
- end
- --print("U: "..u)
- --print("X: "..x)
- --print("X%: "..x % 2)
- end
- resetPos()
Add Comment
Please, Sign In to add comment