Merge branch 'develop' into main

main
Jef Roosens 2020-12-28 17:30:59 +01:00
commit f0fd6ceef7
1 changed files with 24 additions and 2 deletions

View File

@ -150,11 +150,33 @@ local function maintenance(width, depth, sapling_name, log_name)
turtle.turnLeft() turtle.turnLeft()
-- Deposite all logs -- Deposite all logs
while select_item(log_name) do turtle.drop(64) end -- First, find all spots with logs in them
local slots, count = {}, 0
for i = 1, 16 do
local data = turtle.getItemDetail(i)
if data and data.name == log_name then
count = count + data.count
slots[i] = count
end
end
-- Then, deposit logs as long as we have more than 10 logs left
for slot, slot_count in pairs(slots) do
-- Exit the loop if we have 10 or less logs
if count <= 20 then break end
-- Refuel with 64 unless count says otherwise
turtle.select(slot)
local c = math.min(slot_count, count - 20)
turtle.drop(c)
count = count - c
end
-- Keep 10 logs for refueling -- Keep 10 logs for refueling
turtle.select(2) turtle.select(2)
turtle.suck(10) turtle.suck(20 - count)
-- Get back to start block -- Get back to start block
turtle.turnRight() turtle.turnRight()