fix: detect advanced peripherals block reader by type or method
This commit is contained in:
+20
-2
@@ -2,7 +2,7 @@
|
||||
-- ============================================================================
|
||||
-- 1. Configuration & Constants
|
||||
-- ============================================================================
|
||||
local APP_VERSION_TEXT = "v1.0.27"
|
||||
local APP_VERSION_TEXT = "v1.0.28"
|
||||
|
||||
local CONFIG = {
|
||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||
@@ -127,7 +127,25 @@ function Peripherals.init()
|
||||
pcall(Peripherals.createTarget.resize, 80, 10)
|
||||
end
|
||||
-- Block Reader (Advanced Peripherals)
|
||||
Peripherals.blockReader = peripheral.find("blockReader")
|
||||
local blockReader = nil
|
||||
local typeCandidates = { "blockReader", "block_reader", "arBlockReader", "advancedperipherals:block_reader" }
|
||||
for _, t in ipairs(typeCandidates) do
|
||||
local p = peripheral.find(t)
|
||||
if p then
|
||||
blockReader = p
|
||||
break
|
||||
end
|
||||
end
|
||||
if not blockReader and peripheral.getNames then
|
||||
for _, name in ipairs(peripheral.getNames()) do
|
||||
local p = peripheral.wrap(name)
|
||||
if p and type(p.getBlockData) == "function" then
|
||||
blockReader = p
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
Peripherals.blockReader = blockReader
|
||||
end
|
||||
|
||||
-- ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user