public static System.Text.RegularExpressions.Regex ArgExpr; String ArgPattern = @"(\w+)(?:\s*=\s*([\w ]+)|\n)?"; public Program() { ArgExpr = new System.Text.RegularExpressions.Regex(ArgPattern); } public void Main(string argument) { System.Text.RegularExpressions.MatchCollection Matches = ArgExpr.Matches(argument); if(argument != "") { foreach(System.Text.RegularExpressions.Match match in Matches) { Echo(match.Groups[1].Value); if(match.Groups[1].Value == "Reset") { ResetGrid(); } else { if( match.Groups[1].Value == "GridName" ) { Me.CubeGrid.CustomName = match.Groups[2].Value; } Rename(); } } } else { Rename(); } } public void ResetGrid() { List Blocks = new List(); GridTerminalSystem.GetBlocks(Blocks); foreach(IMyTerminalBlock Block in Blocks) { Block.CustomName = Block.DefinitionDisplayNameText + " " + Block.NumberInGrid.ToString(); Block.ShowInTerminal = true; Block.ShowInToolbarConfig = true; } } public void Rename() { List Blocks = new List(); String newName = ""; String Header = ""; GridTerminalSystem.GetBlocksOfType(Blocks, B => IsNotRenamed(B)); foreach(IMyTerminalBlock B in Blocks) { Header = B.CubeGrid.CustomName; Header = Header.Trim(); newName = Header + " " + System.Text.RegularExpressions.Regex.Replace(B.CustomName, @"[\d-]", string.Empty) + " " + B.NumberInGrid.ToString();; B.CustomName = newName; } Echo("Noze Renamed " + Blocks.Count.ToString() + " Blocks."); } public bool IsNotRenamed(IMyTerminalBlock argument) { String name = argument.CubeGrid.CustomName; return !argument.CustomName.Contains(name); }