perf: compact only if needed

This commit is contained in:
Guillaume ARM 2024-05-19 22:04:27 +02:00
parent 66968b0186
commit be8ab78425

View File

@ -1,9 +1,10 @@
local turtleUtils = require('libs/turtle-utils')
local config = require('config/harvesting')
local VERSION = "0.3.0"
local VERSION = "0.3.1"
local IDLE_TIME = 2
local MIN_FUEL_NEEDED = (10 + config.firstCropZ + config.length) * 2
local MIN_FREE_SLOTS_BEFORE_COMPACT = 4
-- UTILS
@ -128,7 +129,9 @@ local function harvestDown()
error('turtle cannot place crop')
end
turtleUtils.compactInventory()
if turtleUtils.countFreeSlots() < MIN_FREE_SLOTS_BEFORE_COMPACT then
turtleUtils.compactInventory()
end
end
local function forward()