diff --git a/build.gradle b/build.gradle index 83ebb890..140588d9 100644 --- a/build.gradle +++ b/build.gradle @@ -137,7 +137,7 @@ System.setProperty("line.separator", "\n") task packageScripts(type: Zip) { archiveFileName = "scripts.zip" - destinationDirectory = file("$buildDir/resources/main/data/oc2/file_systems") + destinationDirectory = file("$buildDir/resources/main/data/oc2r/file_systems") from "src/main/scripts" filter { line -> line } } diff --git a/src/main/scripts/lib/lua/devices.lua b/src/main/scripts/lib/lua/devices.lua index 2c326e1e..66ffcd3c 100644 --- a/src/main/scripts/lib/lua/devices.lua +++ b/src/main/scripts/lib/lua/devices.lua @@ -228,6 +228,31 @@ function DeviceBus:find(deviceTypeName) return nil, "no device of type [" .. deviceTypeName .. "]" end +function DeviceBus:findAll(deviceTypeName) + local devices, status = self:list() + + local found = {} + + if not devices then + return nil, status + end + + for _, device in ipairs(devices) do + if device.typeNames then + for _, typeName in ipairs(device.typeNames) do + if typeName == deviceTypeName then + found[#found+1] = Device:new(self, device) + end + end + end + end + + if #found == 0 then return nil, "no device of type [" .. deviceTypeName .. "]" end + + return found +end + + function DeviceBus:methods(deviceId) self:flush() writeMessage(self, { type = "methods", data = deviceId })