From 2305672157d7539d770333ee5c60836f79f3a35d Mon Sep 17 00:00:00 2001 From: Benedikt Wolf Date: Thu, 16 Mar 2023 16:57:30 +0100 Subject: [PATCH] Autochecklist: Add support for checklists using multiple s --- Aircraft/Generic/autochecklist.nas | 101 ++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 31 deletions(-) diff --git a/Aircraft/Generic/autochecklist.nas b/Aircraft/Generic/autochecklist.nas index 5711fe9ff..fe83a71c1 100644 --- a/Aircraft/Generic/autochecklist.nas +++ b/Aircraft/Generic/autochecklist.nas @@ -228,37 +228,76 @@ var complete = func(node, wait, from = nil) foreach (var index; node.getChildren("index")) { var checklist = checklists_node.getChild("checklist", index.getValue()); - foreach (var item; checklist.getChildren("item")) { - var condition = item.getNode("condition"); - if (skipping) { - if (!item.equals(from)) { - previous_condition = condition; - continue; - } - skipping = 0; - } - if (wait) { - if (props.condition(previous_condition)) { - reset_timeout(); - } else { - if (timed_out()) { - var title = checklist.getNode("title").getValue(); - announce(title~": "~timeout_message.getValue()); - } else { - wait_for_completion(node: node, from: item); - } - return; - } - } - if (!props.condition(condition)) { - foreach (var binding; item.getChildren("binding")) { - active.setValue(1); - props.runBinding(binding); - active.setValue(0); - } - } - previous_condition = condition; - } + if( size( checklist.getChildren("page") ) > 0 ){ + foreach( var page; checklist.getChildren("page") ){ + foreach (var item; page.getChildren("item")) { + var condition = item.getNode("condition"); + if (skipping) { + if (!item.equals(from)) { + previous_condition = condition; + continue; + } + skipping = 0; + } + if (wait) { + if (props.condition(previous_condition)) { + reset_timeout(); + } else { + if (timed_out()) { + var title = checklist.getNode("title").getValue(); + announce(title~": "~timeout_message.getValue()); + } else { + wait_for_completion(node: node, from: item); + } + return; + } + } + if (!props.condition(condition)) { + foreach (var binding; item.getChildren("binding")) { + active.setValue(1); + props.runBinding(binding); + active.setValue(0); + } + } + previous_condition = condition; + } + + } + + } else { + foreach (var item; checklist.getChildren("item")) { + var condition = item.getNode("condition"); + if (skipping) { + if (!item.equals(from)) { + previous_condition = condition; + continue; + } + skipping = 0; + } + if (wait) { + if (props.condition(previous_condition)) { + reset_timeout(); + } else { + if (timed_out()) { + var title = checklist.getNode("title").getValue(); + announce(title~": "~timeout_message.getValue()); + } else { + wait_for_completion(node: node, from: item); + } + return; + } + } + if (!props.condition(condition)) { + foreach (var binding; item.getChildren("binding")) { + active.setValue(1); + props.runBinding(binding); + active.setValue(0); + } + } + previous_condition = condition; + } + } + } if (wait) { announce(completed_message.getValue());