Advertisement
PSquishyP

Untitled

Sep 17th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1.  function takeItems(perph, name, amount)
  2.  
  3.     local f = 1
  4.     local b = nil
  5.     local m = 0
  6.     local d = {}
  7.     local s = perph.getInventorySize()
  8.     local c = "slot?"
  9.     local q = amount
  10.     local n = 0
  11.     for f = 1, s, 1 do
  12.         b = perph.getStackInSlot(f, false)
  13.         c = "slot" .. f
  14.         if type(b) == nil then
  15.             d[c] = "empty"
  16.         elseif type(b) == "nil" then
  17.             d[c] = "empty"
  18.         else
  19.             d[c] = b
  20.             if q == 0 then
  21.                 return "Successfully found " .. amount .. " " .. name
  22.             elseif b.display_name == name then
  23.                 m = perph.pushItem("up",f,q)
  24.                 q = q - m
  25.             end
  26.            
  27.             if q == 0 then
  28.                 return "Successfully found " .. amount .. " " .. name
  29.             end
  30.         end
  31.     end
  32.     n = amount - q
  33.     return "Only found " .. n .. " " .. name
  34.    
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement