1.7.10 compatibility

This commit is contained in:
kepler155c
2018-02-24 03:25:01 -05:00
parent af6435682b
commit 0524f35e57
2 changed files with 17 additions and 10 deletions

View File

@@ -449,8 +449,8 @@ local function findMachines()
local function getName(dir)
local side = turtle.getAction(dir).side
local methods = Peripheral.isPresent(side) and Util.transpose(Peripheral.getMethods(side))
if methods then
if Peripheral.isPresent(side) then
local methods = Util.transpose(Peripheral.getMethods(side))
if methods.getMetadata then
local name = Peripheral.call(side, 'getMetadata').displayName
if name and not string.find(name, '.', 1, true) then
@@ -459,6 +459,7 @@ local function findMachines()
elseif methods.getInventoryName then -- 1.7x
return Peripheral.call(side, 'getInventoryName')
end
return Peripheral.getType(side)
end
local _, machine = turtle.getAction(dir).inspect()
if not machine or type(machine) ~= 'table' then
@@ -1076,7 +1077,14 @@ function listingPage:applyFilter()
self.grid:setValues(t)
end
findMachines()
local s, m = pcall(findMachines)
if not s and m then
printError(m)
read()
return
end
loadResources()
dock()
clearGrid()

View File

@@ -16,7 +16,7 @@ local InventoryAdapter = require('inventoryAdapter')
local colors = _G.colors
local device = _G.device
local multishell = _ENV.multishell
local peripheral = _G.peripheral
local os = _G.os
local term = _G.term
local turtle = _G.turtle
@@ -52,15 +52,14 @@ if device.workbench then
[ 'right' ] = 'left',
}
local duckAntennaSide = oppositeSide[device.workbench.side]
duckAntenna = peripheral.wrap(duckAntennaSide)
if not duckAntenna or not duckAntenna.getAllStacks then
duckAntenna = nil
if Peripheral.getType(duckAntennaSide) == os.getComputerLabel() then
duckAntenna = Peripheral.wrap(duckAntennaSide)
if duckAntenna and not duckAntenna.getAllStacks then
duckAntenna = nil
end
end
end
--TODO : find out duck antenna type
duckAntenna = nil
local STATUS_INFO = 'info'
local STATUS_WARNING = 'warning'
local STATUS_ERROR = 'error'