diff --git a/.gitignore b/.gitignore index f5e2e37..eaa9902 100644 --- a/.gitignore +++ b/.gitignore @@ -361,4 +361,3 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd -/wContainerSorter_Backup_2023-11-03-121529496.zip diff --git a/wContainerSorter/Instructions.readme b/wContainerSorter/Instructions.readme deleted file mode 100644 index ed30ab7..0000000 --- a/wContainerSorter/Instructions.readme +++ /dev/null @@ -1,5 +0,0 @@ -R e a d m e ------------ - -In this file you can include any instructions or other comments you want to have injected onto the -top of your final script. You can safely delete this file if you do not want any such comments. diff --git a/wContainerSorter/Program.cs b/wContainerSorter/Program.cs index 4270f76..d22efc6 100644 --- a/wContainerSorter/Program.cs +++ b/wContainerSorter/Program.cs @@ -1,34 +1,11 @@ -using Sandbox.Game.EntityComponents; -using Sandbox.ModAPI.Ingame; -using Sandbox.ModAPI.Interfaces; - -using SpaceEngineers.Game.ModAPI.Ingame; - -using System; -using System.Collections; +using Sandbox.ModAPI.Ingame; using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using System.Text; - -using VRage; -using VRage.Collections; -using VRage.Game; -using VRage.Game.Components; -using VRage.Game.GUI.TextPanel; using VRage.Game.ModAPI.Ingame; -using VRage.Game.ModAPI.Ingame.Utilities; -using VRage.Game.ObjectBuilders.Definitions; -using VRageMath; +namespace IngameScript { + partial class Program : MyGridProgram { -namespace IngameScript -{ - partial class Program : MyGridProgram - { - - // -------------------------------------------------- - // wContainerSorter, v1.0 + // wContainerSorter, v1.1 // Copyright (c) 2023 by W0LF aka 'dreamforce' // // This script sorts the content of the containers. @@ -40,27 +17,19 @@ namespace IngameScript - // !!! NO CHANGES BELOW !!! // + // =============== !!! NO CHANGES BELOW !!! =============== // static List containers = new List(); static List containerItems = new List(); - public Program() - { + public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update100; } - public void Main(string argument, UpdateType updateSource) - { - //IMyTextPanel lcd = GridTerminalSystem.GetBlockWithName("LCD") as IMyTextPanel; - //lcd.ContentType = ContentType.TEXT_AND_IMAGE; - //lcd.WriteText(""); - + public void Main(string argument, UpdateType updateSource) { containers.Clear(); - GridTerminalSystem.GetBlocksOfType(containers); - foreach (var container in containers) - { + foreach (var container in containers) { containerItems.Clear(); IMyInventory containerInventory = container.GetInventory(); containerInventory.GetItems(containerItems); @@ -68,23 +37,13 @@ namespace IngameScript if (sortType.ToUpper() == "NAME") containerItems.Sort((MyInventoryItem x, MyInventoryItem y) => x.Type.SubtypeId.ToString().CompareTo(y.Type.SubtypeId.ToString())); else containerItems.Sort((MyInventoryItem x, MyInventoryItem y) => x.Type.ToString().CompareTo(y.Type.ToString())); - foreach (MyInventoryItem item in containerItems) - { - for (int i = 0; i < containerInventory.ItemCount; i++) - { + foreach (MyInventoryItem item in containerItems) { + for (int i = 0; i < containerInventory.ItemCount; i++) { MyInventoryItem item2 = (MyInventoryItem)containerInventory.GetItemAt(i); if (item.Equals(item2)) containerInventory.TransferItemTo(containerInventory, i, i + containerInventory.ItemCount, true); } } - - //lcd.WriteText($"{container.CustomName}:\n", true); - //foreach (MyInventoryItem item in containerItems) lcd.WriteText($"{item.Type} - {item.Amount}\n", true); - //lcd.WriteText("\n", true); } } - // -------------------------------------------------- - - - } } diff --git a/wContainerSorter/wContainerSorter.csproj b/wContainerSorter/wContainerSorter.csproj index 9b7b80f..43b5ebd 100644 --- a/wContainerSorter/wContainerSorter.csproj +++ b/wContainerSorter/wContainerSorter.csproj @@ -49,7 +49,6 @@ Always -