GauHelldragon

BioWatch v1.0

May 18th, 2014
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 0 0
  1. local bio = peripheral.wrap("back")
  2. local modem = peripheral.wrap("bottom")
  3. local machine = "tile_mfr_machine_bioreactor_name_0"
  4.  
  5. function getSecondStack(stack)
  6.    return modem.callRemote(machine,"getStackInSlot",stack)
  7. end
  8.  
  9. function isIn(var,tab)
  10.  for i,v in ipairs(tab) do
  11.     if ( v == var ) then return true end
  12.  end
  13.  return false
  14. end
  15.  
  16. function PushItem(slot)
  17.   bio.pushItem("north",slot)
  18. end
  19.  
  20. function checkSecond()
  21.   local count = 0
  22.  
  23.   for i = 1,9 do
  24.     if ( getSecondStack(i) ~= nil ) then count = count + 1 end
  25.   end
  26.   if ( count >= 6 ) then return false end
  27.   count = 0
  28.  
  29.   for i=10,18 do
  30.     if ( getSecondStack(i) ~= nil ) then count = count + 1 end
  31.   end
  32.   if ( count >= 8 ) then return false end  
  33.  
  34.   return true
  35. end
  36.  
  37.  
  38. while true do
  39.  
  40.   local idList = {}
  41.   local numOfTypes = 0
  42. --  print("wee")
  43.   for i=1,9 do
  44.     local item = bio.getStackInSlot(i)
  45.     if (  item ~= nil ) then
  46.       local code = item.id .. "." .. item.dmg
  47.       if ( isIn(code,idList) ) then
  48.     --    print("Pushing " .. i .. " " .. item.id)
  49.         PushItem(i)
  50.       else
  51.   --      print("Adding " .. i .. " ".. item.id)
  52.         table.insert(idList,code)
  53.        
  54.       end
  55.     end
  56.   end  
  57.   for i=10,18 do
  58.     local item = bio.getStackInSlot(i)
  59.     if ( item ~= nil ) then numOfTypes = numOfTypes + 1 end
  60.   end
  61.   local first = true
  62.   local second = checkSecond()
  63.  
  64.   if ( numOfTypes >= 8 ) then
  65.     first = false
  66.     --rs.setAnalogOutput("right",true)
  67.   else
  68.     first = true
  69.     --rs.setOutput("right",false)
  70.   end
  71.   local color = 0
  72.   if ( first ) then color = color + colors.orange end
  73.   if ( second ) then color = color + colors.magenta end
  74.   rs.setBundledOutput("top",color)
  75.  
  76.  
  77.   os.sleep(10)
  78. end
Add Comment
Please, Sign In to add comment