Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bucketList = {"minecraft:bucket", "minecraft:lava_bucket"}
- -- selects slot with bucket
- local function selectBucket()
- local item = turtle.getItemDetail()
- if item then
- if (item.name == bucketList[1]) then
- return true
- end
- if (item.name == bucketList[2]) then
- return true
- end
- end
- for i=1, 16, 1 do
- turtle.select(i)
- item = turtle.getItemDetail()
- if item then
- if (item.name == bucketList[1]) then
- return true
- end
- if (item.name == bucketList[2]) then
- return true
- end
- end
- end
- return false
- end
- --Returns bool bFullTank and bBucketIsEmpty (if fuel is maximum and if bucket contains nothing)
- local function getBucketAndFuelData()
- local fuelLevel = turtle.getFuelLevel()
- local maxFuelLevel = turtle.getFuelLimit()
- local bFullTank = (fuelLevel == maxFuelLevel)
- local bBucketIsEmpty = true
- local item = turtle.getItemDetail()
- if item then
- if (item.name == bucketList[1]) then
- bBucketIsEmpty = true
- end
- if (item.name == bucketList[2]) then
- bBucketIsEmpty = false
- end
- end
- return bFullTank, bBucketIsEmpty
- end
- --collects lava in this direction (tries to use it)
- local function Front(lavaCnt)
- local bFullTank, bEmptyBucket = getBucketAndFuelData()
- local bRefueld = false
- if bEmptyBucket then
- turtle.place()
- end
- if not bFullTank then
- turtle.refuel()
- bRefueld = true
- end
- if not bEmptyBucket then
- turtle.place()
- if not bRefueld then
- turtle.place()
- end
- end
- lavaCnt[1] = lavaCnt[1] + 1
- end
- local function Top(lavaCnt)
- local bFullTank, bEmptyBucket = getBucketAndFuelData()
- local bRefueld = false
- if bEmptyBucket then
- turtle.placeUp()
- end
- if not bFullTank then
- turtle.refuel()
- bRefueld = true
- end
- if not bEmptyBucket then
- turtle.placeUp()
- if not bRefueld then
- turtle.placeUp()
- end
- end
- lavaCnt[1] = lavaCnt[1] + 1
- end
- local function Bottom(lavaCnt)
- local bFullTank, bEmptyBucket = getBucketAndFuelData()
- local bRefueld = false
- if bEmptyBucket then
- turtle.placeDown()
- end
- if not bFullTank then
- turtle.refuel()
- bRefueld = true
- end
- if not bEmptyBucket then
- turtle.placeDown()
- if not bRefueld then
- turtle.placeDown()
- end
- end
- lavaCnt[1] = lavaCnt[1] + 1
- end
- return { selectBucket = selectBucket, Front = Front, Top = Top, Bottom = Bottom}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement