From b00180d780ddaaf945372d08372d2075f99e89f2 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Sat, 25 May 2024 21:28:29 +0200 Subject: [PATCH] chore: cleanup old/simple-harvester --- install.lua | 1 - old/simple-harvester.lua | 99 ---------------------------------------- 2 files changed, 100 deletions(-) delete mode 100644 old/simple-harvester.lua diff --git a/install.lua b/install.lua index 4fe389d..c7d274d 100644 --- a/install.lua +++ b/install.lua @@ -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') diff --git a/old/simple-harvester.lua b/old/simple-harvester.lua deleted file mode 100644 index a45f7b2..0000000 --- a/old/simple-harvester.lua +++ /dev/null @@ -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()