diff --git a/Conveyer/Controller.cs b/Conveyer/Controller.cs index 5dabb40..dfcae44 100644 --- a/Conveyer/Controller.cs +++ b/Conveyer/Controller.cs @@ -12,16 +12,14 @@ class Controller static void Main(string[] args) { - // Check for correct file format and length - + // Check for correct file format and length if (!(args.Length == 1 && args[0].EndsWith(".coy"))) { Console.WriteLine("Code not a valid file"); Console.ReadKey(); return; } - filePath = args[0]; - + filePath = args[0]; height = File.ReadLines(filePath).Count(); FileHandler fh = new FileHandler(filePath); diff --git a/Conveyer/FileHandler.cs b/Conveyer/FileHandler.cs index 7f15199..3771be3 100644 --- a/Conveyer/FileHandler.cs +++ b/Conveyer/FileHandler.cs @@ -28,6 +28,8 @@ void ReadFile(int maxLength, string file, string filePath) { string[] lines = new string[Controller.height]; int lineCounter = 0; + bool addWhite = false; + string temp; const Int32 BufferSize = 128; using (var fileStream = File.OpenRead(file)) @@ -35,9 +37,20 @@ void ReadFile(int maxLength, string file, string filePath) { string line; while ((line = streamReader.ReadLine()) != null) - { + { //Reads file and adds lines to an array lines[lineCounter] = line; + + //Check if there is a blank space at char 1, otherwise add one + if (lines[lineCounter].StartsWith(">") || lines[lineCounter].StartsWith("|") || lines[lineCounter].StartsWith("‾") || lines[lineCounter].StartsWith("_")) + addWhite = true; + + if(addWhite == true) + { + temp = lines[lineCounter].Insert(0, " "); + lines[lineCounter] = temp; + } + Console.WriteLine(lines[lineCounter]); //THIS IS THE GOOD LOOKING DEBUG PRINT lineCounter++; } diff --git a/Conveyer/Scanner.cs b/Conveyer/Scanner.cs index 518d370..8735444 100644 --- a/Conveyer/Scanner.cs +++ b/Conveyer/Scanner.cs @@ -20,9 +20,24 @@ void Scan(int length, char[,] _map) bool moveSideways = true; bool scanFinished = false; - for (int h = 1; h < Controller.height;) + int h = 0; + int l = 0; + + //Check if first belt go right of down and adjust scan + if(_map[1, 1] == '>') + { + h = 1; + l = 2; + } + else if(_map[0, 2] == 'ᵥ') + { + h = 0; + l = 2; + } + + for (; h < Controller.height;) { - for (int l = 2; l < length;) + for (; l < length;) { if (reg.IsMatch(_map[h, l].ToString())) //If current pos has a character to print, queue it { @@ -67,12 +82,12 @@ void Scan(int length, char[,] _map) h--; } - if (_map[h - 1, l - 2] == '_' && goRight == false && moveSideways == true) //Go left + if ((_map[h - 1, l - 2] == '_' || _map[h + 1, l - 2] == '‾') && goRight == false && moveSideways == true) //Go left { l--; } - if (_map[h - 1, l + 2] == '_' && goRight == true && moveSideways == true) //Go right + if ((_map[h - 1, l + 2] == '_' || _map[h + 1, l + 2] == '‾') && goRight == true && moveSideways == true) //Go right { l++; }