Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Import Relative Location Libraries
- local tTurtle = require("TrackingTurtle")
- local myTurtle = tTurtle.create()
- local function checkJunkChest()
- myTurtle.turnLeft()
- for _ = 1, 3 do
- myTurtle.up()
- end
- for _ = 1, 6 do
- myTurtle.forward()
- end
- myTurtle.turnRight()
- for _ = 1, 2 do
- myTurtle.forward()
- end
- myTurtle.turnLeft()
- myTurtle.down()
- for _ = 1, 2 do
- myTurtle.forward()
- end
- myTurtle.turnLeft()
- myTurtle.down()
- end
- local function fillInventory()
- -- Pull items from the chest until the inventory is full
- for slot = 1, 16 do
- if turtle.getItemCount(slot) == 0 then
- -- Select the current slot to store items from the chest
- turtle.select(slot)
- -- Attempt to pull items from the chest
- if turtle.suckDown() then
- print("Pulled items from the chest.")
- else
- -- If no items are left in the chest, stop pulling
- print("No more items in the chest.")
- break
- end
- end
- end
- end
- local function refuel()
- print("refueling")
- local function attemptRefuel(slot)
- turtle.select(slot)
- if turtle.refuel(0) then
- local initialFuelLevel = turtle.getFuelLevel()
- turtle.refuel()
- local fuelIncrease = turtle.getFuelLevel() - initialFuelLevel
- return fuelIncrease
- end
- return 0
- end
- local function burnCoalUntilFull()
- while turtle.getFuelLevel() < turtle.getFuelLimit() do
- local initialFuelLevel = turtle.getFuelLevel()
- if turtle.getItemCount(1) > 0 and turtle.getItemDetail(1).name == "minecraft:coal" then
- turtle.select(1)
- turtle.refuel()
- else
- break
- end
- if turtle.getFuelLevel() == initialFuelLevel then
- break
- end
- end
- end
- -- Attempt to consume items in inventory for refueling
- for slot = 1, 16 do
- local fuelIncrease = attemptRefuel(slot)
- if fuelIncrease > 0 then
- if fuelIncrease < 80 then -- Arbitrary threshold, assuming coal is 80 fuel
- turtle.refuel(math.floor(fuelIncrease / 80)) -- Refuel with coal until it matches consumed item
- end
- return true
- end
- end
- -- Burn coal until fuel is full
- burnCoalUntilFull()
- return turtle.getFuelLevel() == turtle.getFuelLimit() -- Return whether the turtle's fuel is full
- end
- local function sort()
- for i = 1, 16 do
- turtle.select(i)
- local item = turtle.getItemDetail()
- end
- end
- local function stack(itemName)
- print("Checking inventory")
- for slot = 1, 16 do
- if turtle.getItemDetail(slot) then
- local item = turtle.getItemDetail(slot)
- print("Slot: " .. slot .. " Item: " .. item.name)
- if item.name ~= itemName then
- print("this is not" .. itemName)
- turtle.select(slot)
- turtle.drop()
- else
- print(itemName .. " found in slot " .. slot)
- end
- else
- print("Slot: " .. slot .. " is empty")
- end
- end
- end
- local function searchInventory(name)
- for slot = 1, 16 do
- turtle.select(slot)
- local slotDetail = turtle.getItemDetail()
- if slotDetail and slotDetail.name:find(name) then
- return true, slot
- -- Return the slot number if item found
- end
- end
- return false -- Return false if item not found
- end
- local function makeInvar()
- searchInventory("kubejs:nickel_compound")
- turtle.drop()
- sleep(6)
- turtle.suck()
- myTurtle.turnLeft()
- myTurtle.turnLeft()
- searchInventory("kubejs:invar_compound")
- turtle.drop()
- myTurtle.turnRight()
- myTurtle.turnRight()
- sleep(4)
- end
- while true do
- makeInvar()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement