add lava-collector
This commit is contained in:
parent
1c1a6f70a5
commit
2d06761280
77
lava-collector
Normal file
77
lava-collector
Normal file
@ -0,0 +1,77 @@
|
||||
-- vi: ft=lua
|
||||
-- Goal: collect lava using buckets in the nether, deposit the buckets into a fluid transposer that extracts the lava and sends it to a power generator
|
||||
|
||||
local function isEmptyBucket()
|
||||
return turtle.getItemDetail().name == "minecraft:bucket"
|
||||
end
|
||||
|
||||
local function isLavaBucket()
|
||||
return turtle.getItemDetail().name == "minecraft:lava_bucket"
|
||||
end
|
||||
|
||||
local function findFirstEmptyBucket()
|
||||
for i=1,16 do
|
||||
if isEmptyBucket() then
|
||||
print('Slot' .. i .. 'is an empty bucket')
|
||||
return i
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function findFirstLavaBucket()
|
||||
for i=1,16 do
|
||||
if isLavaBucket() then
|
||||
print('Slot' .. i .. 'is an lava bucket')
|
||||
return i
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function returnToBase()
|
||||
print(ForwardCounter)
|
||||
end
|
||||
|
||||
local function despositRefill()
|
||||
end
|
||||
|
||||
local function refuel()
|
||||
local lava_bucket = findFirstLavaBucket()
|
||||
if lava_bucket == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
turtle.select(lava_bucket)
|
||||
turtle.refuel()
|
||||
end
|
||||
|
||||
|
||||
ForwardCounter = 0
|
||||
|
||||
while true do
|
||||
if turtle.getFuelLevel() < 1000 then
|
||||
if refuel() == nil then
|
||||
print('refulling failed. probably the end of the lava lake. returning to base')
|
||||
returnToBase()
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local bucket = findFirstEmptyBucket()
|
||||
|
||||
if bucket == nil then
|
||||
print('could not find any empty buckets. returning and refilling')
|
||||
returnToBase()
|
||||
despositRefill()
|
||||
end
|
||||
|
||||
turtle.select(bucket)
|
||||
-- try to fill it
|
||||
turtle.placeDown()
|
||||
if isEmptyBucket() then
|
||||
if turtle.forward() then
|
||||
ForwardCounter = ForwardCounter + 1
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user