Make chest backend only consider internal chests
This commit is contained in:
parent
2f046e6007
commit
1643151bb3
@ -7,6 +7,8 @@ local d = require "luadash"
|
||||
local conf = w.load_config({
|
||||
"buffer_internal",
|
||||
"buffer_external"
|
||||
}, {
|
||||
"modem_internal" = nil
|
||||
})
|
||||
|
||||
local BUFFER_OUT_SLOT = 1
|
||||
@ -15,7 +17,7 @@ local BUFFER_IN_SLOT = 2
|
||||
-- Find all chests or shulker boxes
|
||||
local inventories = d.map_with_key(w.find_peripherals(function(type, name, wrapped)
|
||||
return string.find(name, "chest") or string.find(name, "shulker")
|
||||
end), function(_, p) return p.name, p.wrapped end)
|
||||
end, conf.modem_internal), function(_, p) return p.name, p.wrapped end)
|
||||
|
||||
local display_name_cache = {}
|
||||
|
||||
|
10
lib.lua
10
lib.lua
@ -225,9 +225,15 @@ local function load_config(required_data, defaults, filename)
|
||||
end
|
||||
|
||||
-- Returns a list of peripheral objects whose type, name and object satisfy the given predicate
|
||||
local function find_peripherals(predicate)
|
||||
local function find_peripherals(predicate, from)
|
||||
local matching = {}
|
||||
for k, name in pairs(peripheral.getNames()) do
|
||||
local list
|
||||
if from then
|
||||
list = peripheral.call(from, "getNamesRemote")
|
||||
else
|
||||
list = peripheral.getNames()
|
||||
end
|
||||
for k, name in pairs(list) do
|
||||
local wrapped = peripheral.wrap(name)
|
||||
local type = peripheral.getType(name)
|
||||
if predicate(type, name, wrapped) then table.insert(matching, { wrapped = wrapped, name = name} ) end
|
||||
|
Loading…
Reference in New Issue
Block a user