From 81d4804d531fc2099a853c2032d75da629389b3a Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Fri, 22 Dec 2023 14:27:40 +0000 Subject: [PATCH] AP_Scripting: examples: update examples for fixed io.open behaviour --- libraries/AP_Scripting/examples/SN-GCJA5-particle-sensor.lua | 3 +++ libraries/AP_Scripting/examples/mission-save.lua | 3 +++ 2 files changed, 6 insertions(+) diff --git a/libraries/AP_Scripting/examples/SN-GCJA5-particle-sensor.lua b/libraries/AP_Scripting/examples/SN-GCJA5-particle-sensor.lua index 08a1f2ad8d..163ae6ca8a 100644 --- a/libraries/AP_Scripting/examples/SN-GCJA5-particle-sensor.lua +++ b/libraries/AP_Scripting/examples/SN-GCJA5-particle-sensor.lua @@ -14,6 +14,9 @@ local file_name while true do file_name = string.format('Particle %i.csv',index) local file = io.open(file_name) + if file == nil then + break + end local first_line = file:read(1) -- try and read the first character io.close(file) if first_line == nil then diff --git a/libraries/AP_Scripting/examples/mission-save.lua b/libraries/AP_Scripting/examples/mission-save.lua index 559d919992..84d19da296 100644 --- a/libraries/AP_Scripting/examples/mission-save.lua +++ b/libraries/AP_Scripting/examples/mission-save.lua @@ -14,6 +14,9 @@ local function save_to_SD() while true do file_name = string.format('%i.waypoints',index) local file = io.open(file_name) + if file == nil then + break + end local first_line = file:read(1) -- try and read the first character io.close(file) if first_line == nil then