Advertisement
systox

seedsorter sort

Oct 28th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. trash = peripheral.wrap("left")
  2. chest = peripheral.wrap("right")
  3. pipe  = peripheral.wrap("right")
  4.  
  5. local function isempty(s)
  6.   return s == nil or s == ''
  7. end
  8.  
  9. function sortPlant(plant_id)
  10.     while true do
  11.         chest.getAvailableItems()
  12.         e, result = os.pullEvent("available_items_return")
  13.         for count, item in pairs(result) do
  14.             local id = pipe.getItemID(v[1])
  15.             if id == 30126 then
  16.                 local iid = item[1]
  17.                 local nbt = pipe.getNBTTagCompound(iid)
  18.                 if (nbt["value"]["id"]["value"] == plant_id) then
  19.                     print("send to chest!")
  20.                     chest.makeRequest(iid,1)
  21.                 else
  22.                     print("send to trash!")
  23.                     trash.makeRequest(iid,1)
  24.                 end
  25.             end
  26.         end
  27.     end
  28. end
  29.  
  30. function sortPlantAfterValues(plant_id, result)
  31.         for count, item in pairs(result) do
  32.         sleep(.2)
  33.             local id = pipe.getItemID(item[1])
  34.             local iid = item[1]
  35.             local nbt = pipe.getNBTTagCompound(iid)
  36.             if id == 30126 then
  37.                 if (nbt["value"]["id"]["value"] == plant_id) then
  38.                     local gr =  nbt["value"]["growth"]["value"]
  39.                     local ga =  nbt["value"]["gain"]["value"]
  40.                     local re =  nbt["value"]["resistance"]["value"]
  41.                     if gr > 20  and gr < 24 then
  42.                         if ga > 30 then
  43.                             if re < 10 then
  44.                                 print("Growth: " .. gr .. " Gain: " .. ga .. " Res.: " .. re .. " --- send to chest!")
  45.                                 chest.makeRequest(iid,1)
  46.                             else
  47.                                 print("Growth: " .. gr .. " Gain: " .. ga .. " Res.: " .. re .. " --- trash!")
  48.                                 trash.makeRequest(iid,1)
  49.                             end
  50.                         else
  51.                             print("Growth: " .. gr .. " Gain: " .. ga .. " Res.: " .. re .. " --- trash!")
  52.                             trash.makeRequest(iid,1)
  53.                         end
  54.                     else
  55.                         print("Growth: " .. gr .. " Gain: " .. ga .. " Res.: " .. re .. " --- trash!")
  56.                         trash.makeRequest(iid,1)
  57.                     end
  58.                 end
  59.             end
  60.         end
  61.         print("Task complete")
  62. end
  63.  
  64.  
  65. while true do
  66.     chest.getAvailableItems()
  67.     e, result = os.pullEvent("available_items_return")
  68.     sortPlantAfterValues(11, result)
  69.     print("wait 60 sec. and start again")
  70.     sleep(60)
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement