Skip to content

Commit

Permalink
Enhanced scanning and internal file formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Abbin44 committed Sep 1, 2020
1 parent bb60b38 commit cb0a399
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
6 changes: 2 additions & 4 deletions Conveyer/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 14 additions & 1 deletion Conveyer/FileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,29 @@ 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))
using (StreamReader streamReader = new StreamReader(fileStream, Encoding.UTF8, true, BufferSize))
{
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++;
}
Expand Down
23 changes: 19 additions & 4 deletions Conveyer/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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++;
}
Expand Down

0 comments on commit cb0a399

Please sign in to comment.