Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ITEMS = {"IC2:itemUran235small", "IC2:itemUran238"}
- CRAFT = {ITEMS[2], ITEMS[2], ITEMS[2], 0,
- ITEMS[1], ITEMS[1], ITEMS[1], 0,
- ITEMS[2], ITEMS[2], ITEMS[2], 0,
- 0, 0, 0, 0}
- function craft()
- for j=1,16 do
- print('fixing slot ' .. j)
- turtle.select(j)
- local name = CRAFT[j]
- if name ~= 0 then
- local sum = 0
- local matches = {}
- for i=1,16 do
- local data = turtle.getItemDetail(i)
- if data and data.name == CRAFT[j] then
- sum = sum + data.count
- matches[#matches+1] = i
- end
- end
- local slots = 0
- for i=1,16 do
- if CRAFT[i] == name then
- slots = slots + 1
- end
- end
- if slots ~= 0 and sum >= slots then
- req = math.floor(sum/slots)
- if req > 64 then
- req = 64
- end
- data = turtle.getItemDetail(j)
- if data then
- found = false
- for i=1,16 do
- if data.name == CRAFT[i] then
- found = true
- break
- end
- end
- if not found then
- turtle.select(j)
- turtle.dropDown()
- print('detected useless item')
- return false
- end
- end
- if data and data.name ~= name then
- turtle.select(j)
- for i=j+1,16 do
- local d = turtle.getItemDetail(i)
- if not d then
- turtle.transferTo(i)
- break
- elseif d and d.name == name and d.count + data.count <= 64 then
- turtle.transferTo(i)
- break
- end
- end
- elseif data and data.name == name and data.count < req then
- local success = false
- for i=1,16 do
- local d = turtle.getItemDetail(i)
- if d and d.name == name then
- if d.name == CRAFT[i] and d.count > req then
- turtle.select(i)
- turtle.transferTo(j, d.count - req)
- elseif d.name ~= CRAFT[i] then
- turtle.select(i)
- turtle.transferTo(j)
- end
- end
- data = turtle.getItemDetail(j)
- if data.count >= req then
- success = true
- break
- end
- end
- if not success then
- print('a, could not transfer enough loot to slot: ' .. j)
- return false
- end
- elseif not data then
- local success = false
- for i=1,16 do
- local d = turtle.getItemDetail(i)
- if d and d.name == name then
- if d.name == CRAFT[i] and d.count > req then
- turtle.select(i)
- turtle.transferTo(j, d.count - req)
- elseif d.name ~= CRAFT[i] then
- turtle.select(i)
- turtle.transferTo(j)
- end
- end
- data = turtle.getItemDetail(j)
- if data and data.count >= req then
- success = true
- break
- end
- end
- if not success then
- print('b, could not transfer enough loot to slot: ' .. j)
- return false
- end
- end
- else
- return false
- end
- end
- end
- return true
- end
- while true do
- turtle.suck()
- if craft() then
- print('true!!!!')
- turtle.craft()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement