Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ihf = peripheral.wrap("front")
- local string = peripheral.wrap("top")
- local wool = peripheral.wrap("left")
- turtle.select(1)
- local function hemp_count()
- local item = ihf.list()[1]
- return item and item.count or 0
- end
- local function step()
- local count = math.floor(math.min(hemp_count(), 64 * 3) / 12) * 4
- if count == 0 then
- print("No hemp available. Waiting..")
- sleep(5)
- return false
- end
- -- Pull hemp in
- ihf.pushItems("north", 1, count, 1)
- ihf.pushItems("north", 1, count, 2)
- ihf.pushItems("north", 1, count, 5)
- while not turtle.craft(count) do
- print("Fix inventory")
- sleep(2)
- end
- -- Push to string chest
- repeat
- count = count - string.pullItems("below", 1)
- if count ~= 0 then
- print("Waiting for space in container...")
- sleep(1)
- end
- until count == 0
- end
- local function count_string()
- local amount = 0
- for slot,item in pairs(string.list()) do
- if item.name == "minecraft:string" then
- amount = amount + item.count
- end
- end
- return amount
- end
- local function craft_wool(count)
- local to_slot = 1
- local to_slot_remaining = count
- for slot,item in pairs(string.list()) do
- if item.name == "minecraft:string" then
- local to_pull = math.min(to_slot_remaining, item.count)
- string.pushItems("below", slot, to_pull, to_slot)
- to_slot_remaining = to_slot_remaining - to_pull
- if to_slot_remaining == 0 then
- to_slot = to_slot + 1
- to_slot_remaining = count
- if to_slot == 3 then
- to_slot = 5
- elseif to_slot == 7 then
- break
- end
- end
- end
- end
- if to_slot ~= 7 then
- error("Failed to fill inventory")
- end
- while not turtle.craft(count) do
- print("Fix inventory")
- sleep(2)
- end
- -- Push to wool container
- repeat
- count = count - wool.pullItems("west", 1)
- if count ~= 0 then
- print("Waiting for space in container...")
- sleep(1)
- end
- until count == 0
- end
- while true do
- step()
- if count_string() >= 256 then
- craft_wool(64)
- end
- sleep(0.05)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement