Advertisement
camarajohnny

thor_V1.3

Feb 15th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. function pickEnder(enderNumber,enderChest) --enderNumber is between 0 and 4096, enderChest is the wrapped chest
  2. b1 = math.floor(enderNumber/ 256) -- find first colour code
  3. b2 = math.floor((enderNumber - (256 *b1)) / 16)
  4. b3 = enderNumber % 16
  5. error = enderChest.setColors(2^b1,2^b2,2^b3)
  6. return error
  7. end -- ends pickEnder()
  8.  
  9. -- function for furnace
  10. function getRecipie(fAddSort,oldData,programChest,startChest) --fixed
  11. local itemsMoved = 0
  12. local ana
  13. local addItem
  14. local fdata ={}
  15. local countItems = 0
  16. local pattern = {}
  17. pickEnder(programChest,fAddSort)
  18. for inv = 1, fAddSort.getInventorySize() do
  19. ana = fAddSort.getStackInSlot(inv)
  20. addItem = 1
  21. if ana == nil then
  22. addItem = 0
  23. else
  24. if #oldData ~= nil then
  25. for i = 1, #oldData, 1 do
  26. if ana.id == oldData[i].id then
  27. addItem = 2
  28. table.insert(oldData[i].slots,inv)
  29. pattern[inv] = i
  30. countItems = countItems + 1
  31. end
  32. end
  33. end
  34. if addItem > 0 then
  35. -- inserts entry into table
  36. table.insert(fdata,{raw_name = ana.raw_name, id = ana.id,name = ana.name, outBox = {startChest}})
  37. if addItem == 1 then
  38. itemsMoved = itemsMoved + 1
  39. table.insert(oldData,{raw_name = ana.raw_name, id = ana.id,name = ana.name, outBox = (startChest + #oldData),slots = {inv}})
  40. print(oldData[#oldData].outBox.." "..#oldData)
  41. pattern[inv] = #oldData
  42.  
  43. countItems = countItems + 1
  44. end
  45. end
  46. end
  47.  
  48. end
  49. return itemsMoved, countItems, pattern, oldData
  50. end
  51.  
  52. function loadInv(enderChest,pattern,recipie,slot)
  53. local isFound = false
  54. local itemTable = {}
  55. local count = 1
  56. pickEnder(recipie[pattern[slot]].outBox,enderChest)
  57. while isFound == false do
  58. itemTable = enderChest.getStackInSlot(count)
  59. if itemTable ~= nil then
  60. if (itemTable.raw_name == recipie[pattern[slot]].raw_name) and (recipie[pattern[slot]].id == itemTable.id) then
  61. enderChest.pushItem("north",count,100,slot)
  62. isFound = true
  63. end
  64. end
  65. count = count + 1
  66. if count > 54 then
  67. return 0
  68. end
  69. end
  70. return 1
  71. end
  72.  
  73. function restartPattern(enderChest,pattern,recipie, sizeOfRecipie)
  74.  
  75. for i = 1, sizeOfRecipie do
  76. turtle.select(i)
  77. loadInv(enderChest,pattern,recipie,i)
  78. end
  79. end
  80.  
  81.  
  82.  
  83. local enderChest = peripheral.wrap("left")
  84. local forge = peripheral.wrap("front")
  85. local recipie = {}
  86. local isChanged = 0
  87. local tank
  88. local blocks = "aluminumbrass.molten"
  89. local side = "right"
  90. local ratio = 2
  91. local count = 1
  92. local sizeOfRecipie = 0
  93. local pattern = {}
  94. turtle.select(1)
  95.  
  96. isChanged, sizeOfRecipie, pattern, recipie = getRecipie(enderChest,recipie,1000,1001)
  97. restartPattern(enderChest,pattern,recipie, sizeOfRecipie)
  98. -- loadInv(enderChest,pattern,recipie,1)
  99. while true do
  100.  
  101. while turtle.drop(4) do
  102. -- if count == (ratio - 1) then
  103. -- turtle.select(count)
  104. -- else
  105. count = count + 1
  106. if count > sizeOfRecipie then
  107. count = 1
  108. end
  109. turtle.select(count)
  110. if turtle.getItemCount() > 0 then
  111. else
  112. loadInv(enderChest,pattern,recipie,count)
  113. turtle.drop(4)
  114. end
  115.  
  116. sleep(.1)
  117. end
  118. -- tank = forge.getInfo()
  119. --if (tank.contents.name == blocks) and
  120. -- if tank.conents ~= nil then
  121. -- print(tank.contents.amont)
  122. -- if (tank.contents.amount >= (1296*2)) then
  123. -- print(tank.contents.name," ",tank.contents.amount)
  124. -- redstone.setOutput(side,false)
  125. -- sleep(0.5)
  126. -- redstone.setOutput(side,true)
  127. -- sleep(11)
  128. -- end
  129. -- sleep(1)
  130. -- end
  131.  
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement