Advertisement
Singleton06

cInv

May 22nd, 2015
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. chest = peripheral.wrap("right")
  2. dropperDirection = "WEST"
  3.  
  4. function getInventory()
  5.   local inventory = {}
  6.   chest.condenseItems()
  7.   for i = 1, chest.getInventorySize() do
  8.    
  9.     currentStack = chest.getStackInSlot(i)
  10.     if currentStack ~= nil then
  11.       inventory[currentStack["display_name"]] = {}
  12.       inventory[currentStack["display_name"]] = currentStack
  13.       currentStack["inventory_slot"] = i
  14.     end
  15.   end
  16.   return inventory
  17. end
  18.  
  19. function dropItem(item)
  20.   inventory = getInventory()
  21.   if inventory[item] == nil then
  22.     print("Could not find item " .. item)
  23.     return
  24.   end
  25.  
  26.   slot = inventory[item]["inventory_slot"]
  27.   chest.pushItem(dropperDirection, slot, 1)
  28. end
  29.  
  30. function dropRecipe(recipe)
  31.   for i, item in pairs(recipe) do
  32.     print ("dropping item " .. item)
  33.    
  34.     dropItem(item)
  35.     sleep(0.3)
  36.   end
  37. end
  38.  
  39. function craftFlower(recipe)
  40.   dropRecipe(recipe)
  41.   dropItem("Seeds")
  42. end
  43.  
  44. function craftFlowers(recipe, num)
  45.   for i = 1, num do
  46.     craftFlower(recipe)
  47.     sleep(3)
  48.   end
  49. end
  50.  
  51. function craftRune(recipe)
  52.   dropRecipe(recipe)
  53.   sleep(5)
  54.   dropItem("Livingrock")
  55. end
  56.  
  57. function craftRunes(recipe, num)
  58.   for i = 1, num do
  59.     craftRune(recipe)
  60.     sleep(2)
  61.   end
  62. end
  63.  
  64. function printInventory()
  65.   inventory = getInventory()
  66.  
  67.   for i,entry in pairs(inventory) do
  68.     print("inventory slot: " .. entry["inventory_slot"])
  69.     print("qty: " .. entry["qty"])
  70.     print("name: " .. entry["display_name"])
  71.   end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement