Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local slots = {
- seeds = 1,
- bonemeal = 2,
- fuel = 3
- }
- local waitTill
- waitTill = function(condition, compare, callback)
- if compare == nil then
- compare = true
- end
- while condition() ~= compare do
- if callback then
- callback()
- end
- os.sleep(0.1)
- end
- return true
- end
- local fuel
- fuel = function(amount)
- if amount == nil then
- amount = 100
- end
- local old = 1
- while turtle.getFuelLevel() < amount do
- print('Fuel level to low, put fuel in slot 16')
- turtle.select(slots.fuel)
- turtle.refuel()
- os.sleep(1)
- end
- return turtle.select(old)
- end
- local forward
- forward = function(steps)
- if steps == nil then
- steps = 1
- end
- if steps < 1 then
- return true
- end
- fuel()
- waitTill(turtle.forward, true)
- return forward(steps - 1)
- end
- local up
- up = function(steps)
- if steps == nil then
- steps = 1
- end
- if steps < 1 then
- return true
- end
- fuel()
- waitTill(turtle.up, true)
- return up(steps - 1)
- end
- local down
- down = function(steps)
- if steps == nil then
- steps = 1
- end
- if steps < 1 then
- return true
- end
- fuel()
- waitTill(turtle.down, true)
- return down(steps - 1)
- end
- local emptyDown
- emptyDown = function(first, last)
- if first == nil then
- first = 1
- end
- if last == nil then
- last = 16
- end
- for slot = first, last do
- turtle.select(slot)
- turtle.dropDown()
- end
- end
- local fertilize
- fertilize = function()
- local initial = turtle.getItemCount(slots.bonemeal)
- if initial < 2 then
- return false
- end
- turtle.select(slots.bonemeal)
- turtle.placeDown()
- if initial ~= turtle.getItemCount(slots.bonemeal) then
- fertilize()
- end
- return true
- end
- turtle.step = function()
- while not fertilize() do
- os.sleep(0.5)
- end
- turtle.select(slots.seeds)
- turtle.digDown()
- return forward()
- end
- forward()
- while turtle.detectDown() do
- step()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement