fix: simplify crafting turtle detection logic by removing unnecessary method checks
This commit is contained in:
@@ -224,20 +224,13 @@ local function main()
|
||||
log.warn("INIT", "No modem found for client sync")
|
||||
end
|
||||
|
||||
-- Detect crafting turtle on network (must have craft() method)
|
||||
-- Detect crafting turtle on network
|
||||
-- The actual craft message goes on CRAFT_CHANNEL which only the crafting
|
||||
-- turtle listens to, so we just need any turtle name for presence checks.
|
||||
for _, name in ipairs(peripheral.getNames()) do
|
||||
if name:match("^turtle_") then
|
||||
local methods = peripheral.getMethods(name)
|
||||
if methods then
|
||||
local hasCraft = false
|
||||
for _, m in ipairs(methods) do
|
||||
if m == "craft" then hasCraft = true; break end
|
||||
end
|
||||
if hasCraft then
|
||||
ctx.craftTurtleName = name
|
||||
break
|
||||
end
|
||||
end
|
||||
ctx.craftTurtleName = name
|
||||
break
|
||||
end
|
||||
end
|
||||
if ctx.craftTurtleName then
|
||||
|
||||
Reference in New Issue
Block a user