fix(coal-creafter): be sure to select slot 1 + fix dropAll
This commit is contained in:
parent
6a50fef10a
commit
a1364a4bff
@ -7,6 +7,7 @@ local IDLE_TIME_ENOUGH_COAL = 120
|
|||||||
local MIN_ESSENCE_NEEDED = 8
|
local MIN_ESSENCE_NEEDED = 8
|
||||||
local COAL_ESSENCE_NAME = 'mysticalagriculture:coal_essence'
|
local COAL_ESSENCE_NAME = 'mysticalagriculture:coal_essence'
|
||||||
local COAL_NAME = 'minecraft:coal'
|
local COAL_NAME = 'minecraft:coal'
|
||||||
|
local CRAFTING_SLOT = 1
|
||||||
|
|
||||||
local STORAGE_BUFFER_SIDE = 'bottom'
|
local STORAGE_BUFFER_SIDE = 'bottom'
|
||||||
local STORAGE_INVENTORY_SIDE = 'front'
|
local STORAGE_INVENTORY_SIDE = 'front'
|
||||||
@ -15,17 +16,29 @@ local dropInStorageFn = turtle.drop
|
|||||||
local suckFromBufferFn = turtle.suckDown
|
local suckFromBufferFn = turtle.suckDown
|
||||||
|
|
||||||
local function dropAll(side, dropFn)
|
local function dropAll(side, dropFn)
|
||||||
|
local previousSelectedSlot = turtle.getSelectedSlot()
|
||||||
|
|
||||||
for i=1, 16, 1 do
|
for i=1, 16, 1 do
|
||||||
local count = turtle.getItemCount(i)
|
local count = turtle.getItemCount(i)
|
||||||
|
|
||||||
if count > 0 then
|
if count > 0 then
|
||||||
turtleUtils.waitForInventory(side, IDLE_TIME)
|
turtleUtils.waitForInventory(side, IDLE_TIME)
|
||||||
|
|
||||||
if not turtleUtils.dropSlot(i, dropFn) then
|
local errorPrinted = false
|
||||||
error('please empty the turtle inventory', 0)
|
while not turtleUtils.dropSlot(i, dropFn) do
|
||||||
|
if not errorPrinted then
|
||||||
|
print('> please empty the turtle inventory')
|
||||||
|
errorPrinted = true
|
||||||
|
end
|
||||||
|
|
||||||
|
os.sleep(WAIT_INVENTORY_TIME)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if previousSelectedSlot ~= turtle.getSelectedSlot() then
|
||||||
|
turtle.select(previousSelectedSlot)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function countCoalItems(inventory)
|
local function countCoalItems(inventory)
|
||||||
@ -116,8 +129,6 @@ local function findStorageChestOrientation()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function main()
|
local function main()
|
||||||
turtle.select(1)
|
|
||||||
|
|
||||||
findStorageChestOrientation()
|
findStorageChestOrientation()
|
||||||
|
|
||||||
print('> Waiting for the back inventory (storage)')
|
print('> Waiting for the back inventory (storage)')
|
||||||
@ -129,6 +140,7 @@ local function main()
|
|||||||
print('> drop all')
|
print('> drop all')
|
||||||
dropAll(STORAGE_INVENTORY_SIDE, dropInStorageFn)
|
dropAll(STORAGE_INVENTORY_SIDE, dropInStorageFn)
|
||||||
|
|
||||||
|
turtle.select(CRAFTING_SLOT)
|
||||||
print('> coal-crafter process started')
|
print('> coal-crafter process started')
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
@ -149,6 +161,7 @@ local function main()
|
|||||||
error('cannot suck into front buffer chest: ' .. tostring(suckErr))
|
error('cannot suck into front buffer chest: ' .. tostring(suckErr))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
turtleUtils.ensureSelected(CRAFTING_SLOT)
|
||||||
prepareCraftShape()
|
prepareCraftShape()
|
||||||
craft()
|
craft()
|
||||||
dropInStorageFn()
|
dropInStorageFn()
|
||||||
|
|||||||
@ -213,6 +213,14 @@ turtleUtils.selectItemBy = function(predicate)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
turtleUtils.ensureSelected = function(slot)
|
||||||
|
if turtle.getSelectedSlot() ~= slot then
|
||||||
|
return turtle.select(slot)
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
turtleUtils.refuel = function(minFuel, suckFn, sleepTime)
|
turtleUtils.refuel = function(minFuel, suckFn, sleepTime)
|
||||||
suckFn = suckFn or turtle.suck
|
suckFn = suckFn or turtle.suck
|
||||||
sleepTime = sleepTime or DEFAULT_IDLE_TIME
|
sleepTime = sleepTime or DEFAULT_IDLE_TIME
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user