MineMcMine

BeeSpecies

Mar 30th, 2022 (edited)
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.68 KB | None | 0 0
  1. --[[
  2.     Using: CC: Tweaked, Plethora
  3.     pastebin run VLMb0xUT
  4.     pastebin get VLMb0xUT startup
  5.     print(textutils.serialize(suggestions))
  6. ]]--
  7.  
  8. apiaryName = "gendustry:industrial_apiary"
  9. samplerName = "gendustry:sampler"
  10. furnaceName = "xu2:tilemachinereceiver"
  11.  
  12. apiary = peripheral.find(apiaryName)
  13. sampler = peripheral.find(samplerName)
  14. furnace = peripheral.find(furnaceName)
  15. beebeeUser = peripheral.find("redstone_integrator")
  16.  
  17. function hasInSlot(slot, name)
  18.     local pot = apiary.getItem(slot)
  19.     if (pot == nil) then
  20.         return false
  21.     end
  22.     return (string.find(pot.getMetadata().name, name) ~= nil)
  23. end
  24.  
  25. function hasInOutput(name)
  26.     local items = apiary.list()
  27.     for i, item in pairs(items) do
  28.         if(string.find(item.name, name) and i > 2) then
  29.             return true
  30.         end
  31.     end
  32.     return false
  33. end
  34.  
  35. function handleQueen()
  36.     beebeeUser.setOutput("down", true)
  37.     os.sleep(1)
  38.     beebeeUser.setOutput("down", false)
  39. end
  40.  
  41. function handlePrincess()
  42.     local items = apiary.list()
  43.     for i, item in pairs(items) do
  44.         if(string.find(item.name, "princess") and i > 2) then
  45.             --print("Moving princess from slot: " .. i)
  46.             apiary.pushItems("self", i)
  47.         end
  48.     end
  49. end
  50.  
  51. function handleDrone()
  52.     local items = apiary.list()
  53.     for i, item in pairs(items) do
  54.         if(string.find(item.name, "drone") and i > 2) then
  55.             --print("Moving drone from slot: " .. i)
  56.             apiary.pushItems("self", i, 1)
  57.         end
  58.     end
  59. end
  60.  
  61. function handleExcessDrones()
  62.     local items = apiary.list()
  63.     for i, item in pairs(items) do
  64.         if(string.find(item.name, "drone") and i > 2) then
  65.             --print("Moving excess drone from slot: " .. i)
  66.             apiary.pushItems(peripheral.getName(sampler), i)
  67.         end
  68.     end
  69. end
  70.  
  71. function hasSpeciesSerum()
  72.     local item = sampler.getItem(4)
  73.     if(item == nil) then
  74.         return nil
  75.     end
  76.  
  77.     print("Got " .. item.getMetadata().displayName)
  78.     return (string.find(item.getMetadata().displayName, "Species") ~= nil)
  79. end
  80.  
  81. function hasLabware()
  82.     local item = sampler.getItem(2)
  83.     if(item == nil) then
  84.         return nil
  85.     end
  86.  
  87.     return (string.find(item.getMetadata().displayName, "Labware") ~= nil)
  88. end
  89.  
  90. beebeeUser.setOutput("top", false)
  91. while(true) do
  92.     if(hasInSlot(1, "queen")) then
  93.         handleQueen()
  94.     end
  95.     if(hasInOutput("princess")) then
  96.         handlePrincess()
  97.     end
  98.     if(not hasInSlot(2, "drone")) then
  99.         handleDrone()
  100.     end
  101.    
  102.     if(not hasLabware()) then
  103.         print("No more labware!")
  104.         do return end
  105.     end
  106.     if(hasSpeciesSerum()) then
  107.         redstone.setOutput("top", true)
  108.         print("Got Species serum!")
  109.         do return end
  110.     else
  111.         sampler.pushItems(peripheral.getName(furnace), 4)
  112.     end
  113.  
  114.     if(hasInOutput("drone")) then
  115.         handleExcessDrones()
  116.     end
  117.     os.sleep(1)
  118. end
  119.  
  120.  
  121.  
Add Comment
Please, Sign In to add comment