SHARE
TWEET

Untitled

a guest Feb 21st, 2020 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function getItemsOfType(itemType)
  3.     local toReturn = 0
  4.     local i = 1
  5.     while i<=16 do
  6.         local itemCount =  turtle.getItemCount(i)
  7.         if (itemCount > 0) then
  8.             if (turtle.getItemDetail(i).name == itemType) then
  9.                 toReturn = toReturn+itemCount
  10.             end
  11.         end
  12.         i = i + 1
  13.     end
  14.    
  15.     return toReturn
  16. end
  17.  
  18. function dropSpecificItemsOfType(itemType,n)
  19.     local returned = 0
  20.     local i = 1
  21.     while i<=16 do
  22.         if n~=returned then
  23.             local itemCount =  turtle.getItemCount(i)
  24.             if (itemCount > 0) then
  25.                 if (turtle.getItemDetail(i).name == itemType) then
  26.                     turtle.select(i)
  27.                     if (n-returned > 64) then --Daca tre mai mult de un stack, drop la tot
  28.                         turtle.drop();
  29.                         returned = returned + 64
  30.                     else
  31.                         turtle.drop(n-returned)
  32.                         returned = n
  33.                     end
  34.                 end
  35.             end
  36.             i = i + 1
  37.         else
  38.             break
  39.         end
  40.     end
  41. end
  42.  
  43. cobbleID = "minecraft:cobblestone"
  44. resinID = "ic2:itemharz"
  45. --ic2:itemharz
  46. totalCobblestone = 0
  47. totalResin = 0
  48. while true do
  49.     local event, p1 = os.pullEvent("turtle_inventory")
  50.    
  51.     local currentCobblestone = getItemsOfType(cobbleID)
  52.     local currentResin = getItemsOfType(resinID)
  53.     print("Current cobble,resin in inv:"..currentCobblestone.." "..currentResin)
  54.     totalCobblestone = totalCobblestone + currentCobblestone
  55.     totalResin = totalResin + currentResin
  56.     print("Total cobblestone, resin: "..totalCobblestone.." "..totalResin)
  57.    
  58.     dropSpecificItemsOfType(cobbleID,currentCobblestone)
  59.     dropSpecificItemsOfType(resinID,currentResin)
  60.     if totalResin < totalCobblestone then
  61.         redstone.setOutput("right",true)
  62.     else
  63.         redstone.setOutput("right",false)
  64.         totalCobblestone = 0
  65.         totalResin = 0
  66.     end
  67. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top