From af6435682bb5dbc8dcc222450b3ee98551443381 Mon Sep 17 00:00:00 2001 From: kepler155c Date: Fri, 23 Feb 2018 13:07:45 -0500 Subject: [PATCH] 1.7.10 compatibility --- apps/Crafter.lua | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/apps/Crafter.lua b/apps/Crafter.lua index 201b0e7..ac4f048 100644 --- a/apps/Crafter.lua +++ b/apps/Crafter.lua @@ -447,11 +447,12 @@ local function findMachines() 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)) if methods 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 return name end @@ -459,30 +460,24 @@ local function findMachines() return Peripheral.call(side, 'getInventoryName') 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 local index = 0 local function getMachine(dir) - local side = turtle.getAction(dir).side - 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, { - name = name, - rawName = name, - index = index, - dir = dir, - order = #machines + 1 - }) - end + local name = getName(dir) + table.insert(machines, { + name = name, + rawName = name, + index = index, + dir = dir, + order = #machines + 1 + }) end repeat