From d65228be6cab7f50d7fbfeeb87da2d7e351351c2 Mon Sep 17 00:00:00 2001
From: TheFGFSEagle <thefgfseagle@gmail.com>
Date: Tue, 3 Oct 2023 21:49:32 +0200
Subject: [PATCH] props.nas: Add function to swap the values of two property
 nodes

---
 Nasal/props.nas | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Nasal/props.nas b/Nasal/props.nas
index ebaeee78d..a7028c7e5 100644
--- a/Nasal/props.nas
+++ b/Nasal/props.nas
@@ -484,6 +484,22 @@ var runBinding = func(node, module = nil) {
     condition(node.getNode("condition")) ? fgcommand(cmd, node) : 0;
 }
 
+##
+# Swaps the value of two property nodes, like the property-swap command
+#
+var swapValues = func(left, right) {
+	if (!isa(left, Node)) {
+		left = props.globals.getNode(left);
+	}
+	if (!isa(right, Node)) {
+		right = props.globals.getNode(right);
+	}
+	var leftValue = left.getValue();
+	var rightValue = right.getValue();
+	left.setValue(rightValue);
+	right.setValue(leftValue);
+}
+
  #---------------------------------------------------------------------------
  # Property / object update manager
  #