Advertisement
demon012

newBeeBreeder

Jul 17th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. -- Todo
  2. -- - Get machine working!
  3. -- my libraries
  4. -- check dir exists, if not make it
  5. if not fs.exists("/libs") then--{{{
  6. fs.makeDir("/libs")
  7. end--}}}
  8.  
  9. function update_lib(pastebin_id, dest_path)--{{{
  10. if fs.exists(dest_path) then
  11. fs.delete(dest_path)
  12. end
  13. shell.run("pastebin get " .. pastebin_id .. " " .. dest_path)
  14. os.loadAPI(dest_path)
  15. end--}}}
  16.  
  17. update_lib("qUpykFN4", "libs/ccmisc")
  18. update_lib("n1S2GpfD", "libs/sorterAPI")
  19.  
  20. -- clear library spam
  21. term.setCursorPos(1,1)
  22. term.clear()
  23. -- end my libraries
  24.  
  25.  
  26. --analyzer info:
  27. --output slots = 8,9,10,11
  28.  
  29. --bee info:
  30. --ids = 13340,
  31.  
  32. BeeBreeder = { analyzer = peripheral.wrap("left"), sorter = peripheral.wrap("interactiveSorter"), beeids = {13340,}, inputChestSide = 4, outputChestSide = 5, analyzerSide = 0, lyserSide = 3, apiarySide = 1 }
  33.  
  34. function BeeBreeder:enoughHoney()--{{{
  35. local tankInfo = self.analyzer.getTanks("left")
  36. if tankInfo[1]["amount"] > 100 then
  37. return true
  38. else
  39. return false
  40. end
  41. end--}}}
  42.  
  43. function BeeBreeder:analyzerHasSpace()--{{{
  44. local invSize = self.analyzer.getSizeInventory()
  45. for slot = 8,11 do
  46. local slotContents = self.analyzer.getStackInSlot(slot)
  47. if slotContents == nil then
  48. return true
  49. end
  50. end
  51. return false
  52. end--}}}
  53.  
  54. function BeeBreeder:sort()
  55. for uuid,count in pairs(self.sorter.list(self.inputChestSide)) do
  56. item = sorterAPI.getID(uuid)
  57.  
  58. if item[1] == 13340 then -- item is a bee
  59. -- check to see if it can be analysed
  60. print("Found bee")
  61. -- if can be analysed analyse the bloody thing
  62. elseif item[1] == 13286 or item[1] == 13289 or item[1] == 26098 then -- pollen
  63. print("Found pollen")
  64. elseif item[1] == 13288 then -- royal jelly
  65. print("Found royal jelly")
  66. else
  67. print("Found id: " .. tostring(item[1]) .. ":" .. tostring(item[2]))
  68. self:sendToOutput(uuid, count)
  69. end
  70. end
  71. end
  72.  
  73. function BeeBreeder:sendToOutput(uuid, quantity)
  74. self.sorter.extract(self.inputChestSide, uuid, self.outputChestSide, quantity)
  75. end
  76.  
  77. breeder = BeeBreeder
  78. breeder.analyzer = peripheral.wrap("left")
  79. breeder.sorter = peripheral.wrap("interactiveSorter_0")
  80.  
  81. while true do
  82. -- wait for stuff to arrive in input box or timer to trigger
  83. event = os.pullEvent()
  84.  
  85. -- examine each item in input chest
  86. breeder:sort()
  87.  
  88. -- if comb, pollen or jelly, or string
  89.  
  90. os.startTimer(30)
  91. end
  92.  
  93. print(analyzerHasSpace(analyzer))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement