Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace CustomScriptingLanguage.Code_Management
- {
- class ReadCode
- {
- public static string scriptpath;
- public static int counter = 0;
- public static string line;
- public static bool showlines = false;
- public static bool skipline = false;
- public static string skipto = null;
- public static string getspaces = null;
- public static bool skipblock = false;
- public static void ReadScript()
- {
- try
- {
- if (File.ReadAllText(scriptpath).StartsWith("::LIONSCRIPT") &&
- File.ReadAllText(scriptpath).EndsWith("LIONSCRIPT::"))
- {
- //You can run this!
- Console.Clear();
- Console.WriteLine("Running Script...");
- Console.WriteLine();
- //Read Lines
- StreamReader file =
- new StreamReader(scriptpath);
- while ((line = file.ReadLine()) != null)
- {
- if(skipblock)
- {
- if(line == $"{getspaces}{skipto}::")
- {
- skipblock = false;
- }
- else
- {
- continue;
- }
- }
- if (skipline)
- {
- skipline = false;
- continue;
- }
- //Check lines and see if they contain keywords
- Code_Management.CodeReact.ReactToCode(line);
- //Get Line
- counter++;
- }
- file.Close();
- }
- else
- {
- //Whoops! you cant run this!
- Console.WriteLine(); Console.WriteLine("Cant run this script...");
- }
- }
- catch (Exception e){ Console.WriteLine(); Console.WriteLine($"Error at line {counter + 1}");}
- //Finish Up
- Console.WriteLine();
- Console.WriteLine("Press 'Enter' to quit...");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement