1.7.10 compatibility

This commit is contained in:
kepler155c
2018-02-23 13:07:45 -05:00
parent 77b2632f3f
commit af6435682b

View File

@@ -447,11 +447,12 @@ local function findMachines()
dock() dock()
local function getName(side) local function getName(dir)
local side = turtle.getAction(dir).side
local methods = Peripheral.isPresent(side) and Util.transpose(Peripheral.getMethods(side)) local methods = Peripheral.isPresent(side) and Util.transpose(Peripheral.getMethods(side))
if methods then if methods then
if methods.getMetadata then if methods.getMetadata then
local name = Peripheral.getMetadata().displayName local name = Peripheral.call(side, 'getMetadata').displayName
if name and not string.find(name, '.', 1, true) then if name and not string.find(name, '.', 1, true) then
return name return name
end end
@@ -459,22 +460,17 @@ local function findMachines()
return Peripheral.call(side, 'getInventoryName') return Peripheral.call(side, 'getInventoryName')
end end
end end
local _, machine = turtle.getAction(dir).inspect()
if not machine or type(machine) ~= 'table' then
return 'Unknown'
end
return machine.name or 'Unknown'
end end
local index = 0 local index = 0
local function getMachine(dir) local function getMachine(dir)
local side = turtle.getAction(dir).side local name = getName(dir)
local machine = Peripheral.getBySide(side)
if not machine then
local _
_, machine = turtle.getAction(dir).inspect()
if not machine or type(machine) ~= 'table' then
machine = { name = 'Unknown' }
end
end
if machine and type(machine) == 'table' then
local name = getName(side) or machine.name
table.insert(machines, { table.insert(machines, {
name = name, name = name,
rawName = name, rawName = name,
@@ -483,7 +479,6 @@ local function findMachines()
order = #machines + 1 order = #machines + 1
}) })
end end
end
repeat repeat
getMachine('down') getMachine('down')