Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pickEnder(enderNumber,enderChest) --enderNumber is between 0 and 4096, enderChest is the wrapped chest
- b1 = math.floor(enderNumber/ 256) -- find first colour code
- b2 = math.floor((enderNumber - (256 *b1)) / 16)
- b3 = enderNumber % 16
- error = enderChest.setColors(2^b1,2^b2,2^b3)
- return error
- end -- ends pickEnder()
- -- function for furnace
- function getRecipie(fAddSort,oldData,programChest,startChest) --fixed
- local itemsMoved = 0
- local ana
- local addItem
- local fdata ={}
- local countItems = 0
- local pattern = {}
- pickEnder(programChest,fAddSort)
- for inv = 1, fAddSort.getInventorySize() do
- ana = fAddSort.getStackInSlot(inv)
- addItem = 1
- if ana == nil then
- addItem = 0
- else
- if #oldData ~= nil then
- for i = 1, #oldData, 1 do
- if ana.id == oldData[i].id then
- addItem = 2
- table.insert(oldData[i].slots,inv)
- pattern[inv] = i
- countItems = countItems + 1
- end
- end
- end
- if addItem > 0 then
- -- inserts entry into table
- table.insert(fdata,{raw_name = ana.raw_name, id = ana.id,name = ana.name, outBox = {startChest}})
- if addItem == 1 then
- itemsMoved = itemsMoved + 1
- table.insert(oldData,{raw_name = ana.raw_name, id = ana.id,name = ana.name, outBox = (startChest + #oldData),slots = {inv}})
- print(oldData[#oldData].outBox.." "..#oldData)
- pattern[inv] = #oldData
- countItems = countItems + 1
- end
- end
- end
- end
- return itemsMoved, countItems, pattern, oldData
- end
- function loadInv(enderChest,pattern,recipie,slot)
- local isFound = false
- local itemTable = {}
- local count = 1
- pickEnder(recipie[pattern[slot]].outBox,enderChest)
- while isFound == false do
- itemTable = enderChest.getStackInSlot(count)
- if itemTable ~= nil then
- if (itemTable.raw_name == recipie[pattern[slot]].raw_name) and (recipie[pattern[slot]].id == itemTable.id) then
- enderChest.pushItem("north",count,100,slot)
- isFound = true
- end
- end
- count = count + 1
- if count > 54 then
- return 0
- end
- end
- return 1
- end
- function restartPattern(enderChest,pattern,recipie, sizeOfRecipie)
- for i = 1, sizeOfRecipie do
- turtle.select(i)
- loadInv(enderChest,pattern,recipie,i)
- end
- end
- local enderChest = peripheral.wrap("left")
- local forge = peripheral.wrap("front")
- local recipie = {}
- local isChanged = 0
- local tank
- local blocks = "aluminumbrass.molten"
- local side = "right"
- local ratio = 2
- local count = 1
- local sizeOfRecipie = 0
- local pattern = {}
- turtle.select(1)
- isChanged, sizeOfRecipie, pattern, recipie = getRecipie(enderChest,recipie,1000,1001)
- restartPattern(enderChest,pattern,recipie, sizeOfRecipie)
- -- loadInv(enderChest,pattern,recipie,1)
- while true do
- while turtle.drop(4) do
- -- if count == (ratio - 1) then
- -- turtle.select(count)
- -- else
- count = count + 1
- if count > sizeOfRecipie then
- count = 1
- end
- turtle.select(count)
- if turtle.getItemCount() > 0 then
- else
- loadInv(enderChest,pattern,recipie,count)
- turtle.drop(4)
- end
- sleep(.1)
- end
- -- tank = forge.getInfo()
- --if (tank.contents.name == blocks) and
- -- if tank.conents ~= nil then
- -- print(tank.contents.amont)
- -- if (tank.contents.amount >= (1296*2)) then
- -- print(tank.contents.name," ",tank.contents.amount)
- -- redstone.setOutput(side,false)
- -- sleep(0.5)
- -- redstone.setOutput(side,true)
- -- sleep(11)
- -- end
- -- sleep(1)
- -- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement