Muzze77

BeeController

May 30th, 2022 (edited)
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.76 KB | None | 0 0
  1. shell.run("clear")
  2. dbcol = colors.black
  3. dtcol = colors.white
  4.  
  5. function mbut(cx,cy,text,bcol,tcol)
  6.     if bcol == nil then
  7.         bcol = dbcol
  8.     end
  9.     if tcol == nil then
  10.         tcol = dtcol
  11.     end
  12.     mon.setCursorPos(cx,cy)
  13.     mon.setBackgroundColor(bcol)
  14.     mon.setTextColor(tcol)
  15.     mon.write(text)
  16.     mon.setBackgroundColor(dbcol)
  17.     mon.setTextColor(dtcol)
  18. end
  19.  
  20. while true do
  21.  
  22. machines = peripheral.getNames()
  23. apis = {}
  24. mon = {}
  25. apichest = {}
  26. chest = {}
  27. chestAPI = ""
  28. apichestAPI = ""
  29. gx = 0
  30. gy = 0
  31. for v, k in pairs(machines) do
  32.     if string.find(k,"apiar") ~= nil then
  33.         table.insert(apis,k)
  34.     elseif string.find(k, "monitor") ~= nil then
  35.         mon = peripheral.wrap(k)
  36.         gx,gy = mon.getSize()
  37.         mon.setTextScale(0.5)
  38.     elseif string.find(k, "binniecore") ~= nil then
  39.         apichest = peripheral.wrap(k)
  40.         apichestAPI = k
  41.     elseif string.find(k, "ironchest") ~= nil then
  42.         chest = peripheral.wrap(k)
  43.         chestAPI = k
  44.     end
  45. end
  46.  
  47. if mon == nil then
  48.     error("No Monitor is attached")
  49. end
  50. if chest == nil then
  51.     error("No Ironchest (Copper,Iron,Silver,Diamond) is attached")
  52. end
  53. if apichest == nil then
  54.     error("No Binniechest is attached")
  55. end
  56. if apis == nil then
  57.     error("No Apiarys are attached")
  58. end
  59.  
  60.  
  61. shell.run("clear")
  62. dbcol = colors.black
  63. dtcol = colors.white
  64.  
  65. function mbut(cx,cy,text,bcol,tcol)
  66.     if bcol == nil then
  67.         bcol = dbcol
  68.     end
  69.     if tcol == nil then
  70.         tcol = dtcol
  71.     end
  72.     mon.setCursorPos(cx,cy)
  73.     mon.setBackgroundColor(bcol)
  74.     mon.setTextColor(tcol)
  75.     mon.write(text)
  76.     mon.setBackgroundColor(dbcol)
  77.     mon.setTextColor(dtcol)
  78. end
  79.  
  80. while true do
  81.  
  82. machines = peripheral.getNames()
  83. apis = {}
  84. mon = {}
  85. apichest = {}
  86. chest = {}
  87. chestAPI = ""
  88. apichestAPI = ""
  89. gx = 0
  90. gy = 0
  91. for v, k in pairs(machines) do
  92.     if string.find(k,"apiar") ~= nil then
  93.         table.insert(apis,k)
  94.     elseif string.find(k, "monitor") ~= nil then
  95.         mon = peripheral.wrap(k)
  96.         gx,gy = mon.getSize()
  97.         mon.setTextScale(0.5)
  98.     elseif string.find(k, "binniecore") ~= nil then
  99.         apichest = peripheral.wrap(k)
  100.         apichestAPI = k
  101.     elseif string.find(k, "ironchest") ~= nil then
  102.         chest = peripheral.wrap(k)
  103.         chestAPI = k
  104.     end
  105. end
  106.  
  107.  
  108. if mon == nil then
  109.     error("No Monitor is attached")
  110. end
  111. if chest == nil then
  112.     error("No Ironchest (Copper,Iron,Silver,Gold,Diamond) is attached ")
  113. end
  114. if apichest == nil then
  115.     error("No Binniechest (Copper,Iron,Silver,Gold,Diamond) is attached ")
  116. end
  117. if apis == nil then
  118.     error("No Apiarys are attached ")
  119. end
  120.  
  121. x = 2
  122. y = 2
  123. mbut(x,y,"Machines:")
  124. for value, machine in pairs(apis) do
  125.     api = peripheral.wrap(machine)
  126.     api_list = api.list()
  127.     queen = api.getItemMeta(1)
  128.     drone = api.getItemMeta(2)
  129.     slots = {}
  130.     slots[3] = api.getItemMeta(3)
  131.     slots[4] = api.getItemMeta(4)
  132.     slots[5] = api.getItemMeta(5)
  133.     slots[6] = api.getItemMeta(6)
  134.     slots[7] = api.getItemMeta(7)
  135.     slots[8] = api.getItemMeta(8)
  136.     slots[9] = api.getItemMeta(9)
  137.    
  138.     if queen == nil then
  139.         queen = {}
  140.         queen["displayName"] = "None"
  141.         queen["count"] = 0
  142.     end
  143.     if drone == nil then
  144.         drone = {}
  145.         drone["displayName"] = "None"
  146.         drone["count"] = 0
  147.     end
  148.  
  149.     y = y + 2
  150.     mbut(2,y,"                         ")
  151.     mbut(2,y,machine)
  152.     y = y + 1
  153.     mbut(2,y,"                                                                  ")
  154.     mbut(2,y,"1: " .. queen.displayName)
  155.     mbut(32,y,"2: " .. drone.displayName)
  156.    
  157.     for slotID = 3,9,1 do
  158.         mod = slotID % 2
  159.         if mod == 1 then
  160.             x = 2
  161.             y = y + 1
  162.         else
  163.             x = 32
  164.            
  165.         end
  166.         slots[slotID] = api.getItemMeta(slotID)
  167.         if slots[slotID] == nil then
  168.             slots[slotID] = {}
  169.             slots[slotID]["displayName"] = "None"
  170.             slots[slotID]["count"] = 0
  171.         end
  172.         print(slots[slotID].displayName)
  173.         if string.find(slots[slotID].displayName,"Princess") ~= nil then
  174.             if queen.displayName == "None" then
  175.                  api.pullItems("self",slotID,1,1)
  176.             end
  177.         end
  178.         if string.find(slots[slotID].displayName,"Drone") ~= nil then
  179.             if drone.displayName == "None" then
  180.                  api.pullItems("self",slotID,1,2)
  181.             else
  182.                 for id = 1, 400,1 do
  183.                     if apichest.getItemMeta(id) == nil then
  184.                             api.pushItems(apichestAPI,slotID,slots[slotID].count,id)
  185.                             break
  186.                     end
  187.                 end
  188.             end
  189.         end
  190.         if string.find(slots[slotID].displayName,"Comb") ~= nil or string.find(slots[slotID].displayName,"Pollen") ~= nil then
  191.             chestlist = chest.list()
  192.             for id,value in pairs(chestlist) do
  193.                 if chest.getItemMeta(id).displayName == slots[slotID].displayName then
  194.                     api.pushItems(chestAPI,slotID,slots[slotID].count,id)
  195.                     break
  196.                 elseif chest.getItemMeta(id) == nil then
  197.                     api.pushItems(chestAPI,slotID,slots[slotID].count,id)
  198.                     break
  199.                 end
  200.                    
  201.             end
  202.         end    
  203.         mbut(x,y,"                                                                  ")
  204.         mbut(x,y,slotID  .. ": " .. slots[slotID].displayName)
  205.         mbut(2,gy,"                                                                  ")
  206.         mbut(2,gy,"Machine: " .. machine ..  " Slot: " .. slotID)
  207.     end
  208.        
  209.         y = y + 1
  210.     sleep(0.5)     
  211. end
  212.  
  213.  
  214. mbut(2,gy,"                                                                  ")
  215. mbut(gx/2-4,gy,"DONE")
  216. sleep(0.5)
  217.  
  218. end
  219.  
  220.  
  221.  
  222. x = 2
  223. y = 2
  224. mbut(x,y,"Machines:")
  225. for value, machine in pairs(apis) do
  226.     api = peripheral.wrap(machine)
  227.     api_list = api.list()
  228.     queen = api.getItemMeta(1)
  229.     drone = api.getItemMeta(2)
  230.     slots = {}
  231.     slots[3] = api.getItemMeta(3)
  232.     slots[4] = api.getItemMeta(4)
  233.     slots[5] = api.getItemMeta(5)
  234.     slots[6] = api.getItemMeta(6)
  235.     slots[7] = api.getItemMeta(7)
  236.     slots[8] = api.getItemMeta(8)
  237.     slots[9] = api.getItemMeta(9)
  238.    
  239.     if queen == nil then
  240.         queen = {}
  241.         queen["displayName"] = "None"
  242.         queen["count"] = 0
  243.     end
  244.     if drone == nil then
  245.         drone = {}
  246.         drone["displayName"] = "None"
  247.         drone["count"] = 0
  248.     end
  249.  
  250.     y = y + 2
  251.     mbut(2,y,"                         ")
  252.     mbut(2,y,machine)
  253.     y = y + 1
  254.     mbut(2,y,"                                                                  ")
  255.     mbut(2,y,"1: " .. queen.displayName)
  256.     mbut(32,y,"2: " .. drone.displayName)
  257.    
  258.     for slotID = 3,9,1 do
  259.         mod = slotID % 2
  260.         if mod == 1 then
  261.             x = 2
  262.             y = y + 1
  263.         else
  264.             x = 32
  265.            
  266.         end
  267.         slots[slotID] = api.getItemMeta(slotID)
  268.         if slots[slotID] == nil then
  269.             slots[slotID] = {}
  270.             slots[slotID]["displayName"] = "None"
  271.             slots[slotID]["count"] = 0
  272.         end
  273.         print(slots[slotID].displayName)
  274.         if string.find(slots[slotID].displayName,"Princess") ~= nil then
  275.             if queen.displayName == "None" then
  276.                  api.pullItems("self",slotID,1,1)
  277.             end
  278.         end
  279.         if string.find(slots[slotID].displayName,"Drone") ~= nil then
  280.             if drone.displayName == "None" then
  281.                  api.pullItems("self",slotID,1,2)
  282.             else
  283.                 for id = 1, 400,1 do
  284.                     if apichest.getItemMeta(id) == nil then
  285.                             api.pushItems(apichestAPI,slotID,slots[slotID].count,id)
  286.                             break
  287.                     end
  288.                 end
  289.             end
  290.         end
  291.         if string.find(slots[slotID].displayName,"Comb") ~= nil or string.find(slots[slotID].displayName,"Pollen") ~= nil then
  292.             chestlist = chest.list()
  293.             for id,value in pairs(chestlist) do
  294.                 if chest.getItemMeta(id).displayName == slots[slotID].displayName then
  295.                     api.pushItems(chestAPI,slotID,slots[slotID].count,id)
  296.                     break
  297.                 elseif chest.getItemMeta(id) == nil then
  298.                     api.pushItems(chestAPI,slotID,slots[slotID].count,id)
  299.                     break
  300.                 end
  301.                    
  302.             end
  303.         end    
  304.         mbut(x,y,"                                                                  ")
  305.         mbut(x,y,slotID  .. ": " .. slots[slotID].displayName)
  306.         mbut(2,gy,"                                                                  ")
  307.         mbut(2,gy,"Machine: " .. machine ..  " Slot: " .. slotID)
  308.     end
  309.        
  310.         y = y + 1
  311.     sleep(0.5)     
  312. end
  313.  
  314.  
  315. mbut(2,gy,"                                                                  ")
  316. mbut(gx/2-4,gy,"DONE")
  317. sleep(0.5)
  318.  
  319. end
Add Comment
Please, Sign In to add comment