diff --git a/src/Artemis.Core/Artemis.Core.csproj.DotSettings b/src/Artemis.Core/Artemis.Core.csproj.DotSettings
index c23015925..57c6a2f5f 100644
--- a/src/Artemis.Core/Artemis.Core.csproj.DotSettings
+++ b/src/Artemis.Core/Artemis.Core.csproj.DotSettings
@@ -93,6 +93,7 @@
True
True
True
+ True
True
True
True
\ No newline at end of file
diff --git a/src/Artemis.Core/VisualScripting/Extensions/NodeScriptExtension.cs b/src/Artemis.Core/VisualScripting/Extensions/NodeScriptExtension.cs
index f0961dfb6..92d583d99 100644
--- a/src/Artemis.Core/VisualScripting/Extensions/NodeScriptExtension.cs
+++ b/src/Artemis.Core/VisualScripting/Extensions/NodeScriptExtension.cs
@@ -19,7 +19,7 @@ public static class NodeScriptExtension
levels[currentLevelNode] = 0; // DarthAffe 13.09.2022: Init-exit nodes as zero
int currentLevel = 1;
- while (currentLevelNodes.Count > 0)
+ while (currentLevelNodes.Count > 0 && currentLevel < 1000)
{
List nextLevelNodes = currentLevelNodes.SelectMany(node => node.Pins
.Where(x => x.Direction == PinDirection.Input)
diff --git a/src/Artemis.UI.Shared/Services/NodeEditor/Commands/OrganizeScript.cs b/src/Artemis.UI.Shared/Services/NodeEditor/Commands/OrganizeScript.cs
new file mode 100644
index 000000000..cd7f3ec23
--- /dev/null
+++ b/src/Artemis.UI.Shared/Services/NodeEditor/Commands/OrganizeScript.cs
@@ -0,0 +1,43 @@
+using System.Collections.Generic;
+using System.Linq;
+using Artemis.Core;
+
+namespace Artemis.UI.Shared.Services.NodeEditor.Commands;
+
+///
+/// Represents a node editor command that can be used to organize a script
+///
+public class OrganizeScript : INodeEditorCommand
+{
+ private readonly NodeScript _script;
+ private readonly List<(INode node, double x, double y)> _originalPositions;
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The script to organize.
+ public OrganizeScript(NodeScript script)
+ {
+ _script = script;
+ _originalPositions = script.Nodes.Select(n => (n, n.X, n.Y)).ToList();
+ }
+
+ ///
+ public string DisplayName => "Organize script";
+
+ ///
+ public void Execute()
+ {
+ _script.Organize();
+ }
+
+ ///
+ public void Undo()
+ {
+ foreach ((INode? node, double x, double y) in _originalPositions)
+ {
+ node.X = x;
+ node.Y = y;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml b/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml
index e37a84702..3ccf5989b 100644
--- a/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml
+++ b/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml
@@ -43,6 +43,11 @@
+