chore: cleanup old/simple-harvester

This commit is contained in:
Guillaume ARM 2024-05-25 21:28:29 +02:00
parent aba45e6b47
commit b00180d780
2 changed files with 0 additions and 100 deletions

View File

@ -73,7 +73,6 @@ local installConfig = function(list)
end
local prepareDirs = function()
fs.makeDir('/old')
fs.makeDir('/libs')
fs.makeDir('/libs/ui')
fs.makeDir('/config')

View File

@ -1,99 +0,0 @@
local VERSION = "0.1.0"
local IDLE_TIME = 2
function isMatureCrop()
local isBlock, block = turtle.inspect()
local blockStateAge = block and block.state and block.state.age
return blockStateAge == 7
end
function isInventory()
local periph = peripheral.wrap('front')
if not periph then
return false
end
return peripheral.hasType(periph, 'inventory')
end
function isSeed(item)
local tags = item.tags or {}
return tags['forge:seeds'] or tags['mysticalagriculture:seeds'] or false
end
function selectSeed()
for i=1, 16,1 do
local details = turtle.getItemDetail(i, true)
if details and isSeed(details) then
turtle.select(i)
return true
end
end
error("selectSeed error: seed not found")
end
function strictDrop(idx)
if turtle.getSelectedSlot() ~= idx then
turtle.select(idx)
end
local ok, err = turtle.drop()
if not ok then
error('strictDrop error: ' .. err)
end
return true
end
function dropAll()
for i=1, 16, 1 do
local count = turtle.getItemCount(i)
if count > 0 then
strictDrop(i)
end
end
end
function waitFor(predicate, sleepTime)
while true do
local result = predicate()
if result ~= nil and result ~= false then
return result
end
os.sleep(sleepTime)
end
end
function emptyInventory()
turtle.turnLeft()
turtle.turnLeft()
waitFor(isInventory, IDLE_TIME)
dropAll()
turtle.turnLeft()
turtle.turnLeft()
end
function main()
while true do
waitFor(isMatureCrop, IDLE_TIME)
turtle.dig()
selectSeed()
turtle.place()
emptyInventory()
end
end
print("Starting Trap's simple harvester v" .. VERSION)
print("=========================")
print()
main()