chore: cleanup old/simple-harvester
This commit is contained in:
parent
aba45e6b47
commit
b00180d780
@ -73,7 +73,6 @@ local installConfig = function(list)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local prepareDirs = function()
|
local prepareDirs = function()
|
||||||
fs.makeDir('/old')
|
|
||||||
fs.makeDir('/libs')
|
fs.makeDir('/libs')
|
||||||
fs.makeDir('/libs/ui')
|
fs.makeDir('/libs/ui')
|
||||||
fs.makeDir('/config')
|
fs.makeDir('/config')
|
||||||
|
|||||||
@ -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()
|
|
||||||
Loading…
Reference in New Issue
Block a user