Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local chest = peripheral.wrap("bottom")
- local chestToTurtle = "up"
- local jarSide = "top"
- local tSlot = 1
- local aspect = "herba"
- function printItemSlot(slot)
- if slot.display_name ~= nil then print("display_name : "..slot.display_name) end
- if slot.qty ~= nil then print("qty : "..slot.qty) end
- if slot.max_size ~= nil then print("max_size : "..slot.max_size) end
- if slot.max_dmg ~= nil then print("max_dmg : "..slot.max_dmg) end
- if slot.raw_name ~= nil then print("raw_name : "..slot.raw_name) end
- if slot.dmg ~= nil then print("dmg : "..slot.dmg) end
- if slot.id ~= nil then print("id : "..slot.id) end
- if slot.name ~= nil then print("name : "..slot.name) end
- --if slot.mod_id ~= nil then print("mod_id : "..slot.mod_id) end
- end
- function emptyJarSlot()
- local as = chest.getAllStacks(false)
- for slot,content in pairs(as) do
- if content.name == "blockJar" then
- return slot
- end
- end
- return 0
- end
- function init()
- print("Emptying turtle inventory")
- for i=1,16 do
- if turtle.getItemCount(i) > 0 then
- chest.pullItem(chestToTurtle,i)
- end
- end
- while not turtle.detectUp() do
- print("No Jar refilling!")
- while turtle.getItemCount(tSlot) < 1 do
- print("Retrieving an empty jar from the chest")
- local ejs =emptyJarSlot()
- if ejs > 0 then
- chest.pushItemIntoSlot(chestToTurtle,ejs,tSlot,1)
- end
- sleep(1)
- end
- print("The empty Jar has been retrieved from the chest")
- turtle.select(tSlot)
- print("Place the empty jar for refilling")
- while not turtle.placeUp() do
- print("Cannot place the jar. Retry in a few seconds...")
- sleep(1)
- end
- sleep(1)
- end
- end
- function getHerbaLevel(side)
- return peripheral.call(side,"getAspectCount",aspect)
- end
- function getFullJar()
- if not turtle.detectUp() then
- print("No jar refilling")
- return false
- end
- while getHerbaLevel(jarSide) < 64 do
- print("Jar not filled yet. Waiting...")
- sleep(2)
- end
- turtle.select(tSlot)
- while not turtle.digUp() do
- print("Cannot dig the jar. Retry in a few seconds...")
- sleep(1)
- end
- if turtle.getItemCount(tSlot) < 1 then
- print("Jar digged but not found in turtle inventory.")
- return false
- end
- while turtle.getItemCount(tSlot) > 0 do
- chest.pullItem(chestToTurtle,tSlot)
- sleep(1)
- end
- print("Jar sent to cheest")
- return true
- end
- while true do
- init()
- getFullJar()
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement