Advertisement
Ranger15

computercraft chest inventory test

May 9th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. local names = peripheral.getNames()
  2.         if names ~= nil then
  3.             local chests = {}
  4.             for _, name in ipairs(names) do
  5.            
  6.                 local wrapped = peripheral.wrap(name)
  7.                 if wrapped.getTransferLocations then
  8.                     chests[name] = wrapped
  9.                 end
  10.             end
  11.             for _, chest in ipairs(chests) do
  12.                 for slot,_ in ipairs(chest.list()) do
  13.                     local itemName = chest[slot].name
  14.                     if itemName == "minecraft:coal" or itemName == "minecraft:planks" or itemName == "minecraft:log" then
  15.                         local target = chest.getTransferLocations()
  16.                         for i, v in ipairs(target) do
  17.                             if v:match("^turtle") then
  18.                                 target = v
  19.                                 break
  20.                             end
  21.                         end
  22.                     chest.pushItem(target, slot)
  23.                 end
  24.             end
  25.         end
  26.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement