Fix stuff

This commit is contained in:
osmarks 2018-07-26 22:07:27 +01:00
parent a0c445d2ce
commit ce9f65ac7a
2 changed files with 4 additions and 4 deletions

View File

@ -13,9 +13,9 @@ local BUFFER_OUT_SLOT = 1
local BUFFER_IN_SLOT = 2
-- Find all chests or shulker boxes
local inventories = w.find_peripherals(function(type, name, wrapped)
local inventories = d.map_with_key(function(_, p) return p.name, p.wrapped end, w.find_peripherals(function(type, name, wrapped)
return string.find(name, "chest") or string.find(name, "shulker")
end)
end))
local display_name_cache = {}

View File

@ -188,14 +188,14 @@ local function find_peripherals(predicate)
for k, name in pairs(peripheral.getNames()) do
local wrapped = peripheral.wrap(name)
local type = peripheral.getType(name)
if predicate(type, name, wrapped) then table.insert(matching, wrapped) end
if predicate(type, name, wrapped) then table.insert(matching, { wrapped = wrapped, name = name} ) end
end
return matching
end
-- Set up stuff for running this library's features (currently, modem initialization)
local function init()
d.map(find_peripherals(function(type, name, wrapped) return type == "modem" end), rednet.open)
d.map(find_peripherals(function(type, name, wrapped) return type == "modem" end), function(p) rednet.open(p.name) end)
end
return { errors = errors, serve = serve, query_by_ID = query_by_ID, query_by_type = query_by_type, get_internal_identifier = get_internal_identifier, load_config = load_config, find_peripherals = find_peripherals, init = init }