Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function SearchItem(target)
- if turtle.getItemCount() > 0 and string.find(turtle.getItemDetail().name, target) ~= nil then
- return
- end
- for i = 1, 16, 1 do
- turtle.select(i)
- if turtle.getItemCount() > 0 and string.find(turtle.getItemDetail().name, target) ~= nil then
- return
- end
- end
- error("No " .. target .. " found")
- end
- function CheckForGrid(i)
- grid = {1, 2, 3, 5, 7, 9, 10, 11}
- for j = 1, 8, 1 do
- if grid[j] == i then
- return true
- end
- end
- return false
- end
- function OrganizePlanks()
- count = 0
- slots = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- for i = 1, 16, 1 do
- turtle.select(i)
- if turtle.getItemCount() > 0 then
- item = turtle.getItemDetail()
- if string.find(item.name, "plank") ~= nil then
- count = count + item.count
- slots[i] = item.count
- elseif i ~= 6 then
- turtle.dropUp()
- end
- end
- end
- x = count % 8
- count = count - x
- targetCount = count / 8
- if targetCount > 64 then
- targetCount = 64
- end
- for i = 1, 11, 1 do
- if CheckForGrid(i) then
- if slots[i] < targetCount then
- missing = targetCount - slots[i]
- for j = 1, 16, 1 do
- if i ~= j then
- over = slots[j]
- if CheckForGrid(j) then
- over = over - targetCount
- end
- if over > 0 then
- transfer = missing
- if missing > over then
- transfer = over
- end
- turtle.select(j)
- turtle.transferTo(i, transfer)
- slots[j] = slots[j] - transfer
- slots[i] = slots[i] + transfer
- end
- end
- end
- end
- end
- end
- for i = 1, 16, 1 do
- if i ~= 6 then
- turtle.select(i)
- c = turtle.getItemCount()
- if c > targetCount then
- turtle.dropUp(c - targetCount)
- end
- end
- end
- return targetCount
- end
- function RefillBucket()
- turtle.select(6)
- if turtle.getItemCount() > 0 and turtle.getItemDetail().name == "immersiveengineering:creosote_bucket" then
- return true
- end
- turtle.drop()
- while turtle.suck() do
- if turtle.getItemCount() > 0 then
- item = turtle.getItemDetail()
- if string.find(item.name, "bucket") == nil then
- turtle.dropUp()
- else
- return true
- end
- end
- end
- return false
- end
- turtle.select(6)
- if turtle.getItemCount() > 0 and string.find(turtle.getItemDetail().name, "bucket") ~= nil then
- for i = 1, 16, 1 do
- turtle.select(i)
- if turtle.getItemCount == 0 then
- turtle.select(6)
- turtle.transferTo(i)
- end
- end
- end
- SearchItem("bucket")
- if turtle.getSelectedSlot() ~= 6 then
- turtle.transferTo(6)
- end
- i = OrganizePlanks()
- while i > 0 do
- if not RefillBucket() then
- error("No more creosote oil :(")
- end
- turtle.craft()
- turtle.select(8)
- turtle.dropUp()
- i = i - 1
- end
- turtle.select(7)
- turtle.dropUp()
Add Comment
Please, Sign In to add comment