better detection for adapters

This commit is contained in:
kepler155c
2017-10-15 02:35:40 -04:00
parent 728cda2215
commit d0c8d2dc4f
4 changed files with 20 additions and 9 deletions

View File

@@ -23,12 +23,26 @@ function ChestAdapter:init(args)
Util.merge(self, defaults)
Util.merge(self, args)
local chest = Peripheral.getBySide(self.wrapSide)
local chest
if not self.autoDetect then
chest = Peripheral.getBySide(self.wrapSide)
if chest and not chest.list then
chest = nil
end
end
if not chest then
chest = Peripheral.getByMethod('list')
end
if chest then
Util.merge(self, chest)
local sides = {
top = 'down',
bottom = 'up',
}
self.direction = sides[self.side] or self.direction
end
end