public static void LoadScripts() { if (Directory.Exists(Application.StartupPath + "\\Scripts")) { string[] startupScripts = Directory.GetFiles(Application.StartupPath + "\\Scripts"); foreach (string scriptPath in startupScripts) { if (scriptPath.EndsWith(".lua") || scriptPath.EndsWith(".js")) { commandv("load-script", $"{scriptPath}"); } } foreach (string scriptPath in startupScripts) { if (Path.GetExtension(scriptPath) == ".py") { PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); } } foreach (string scriptPath in startupScripts) { if (Path.GetExtension(scriptPath) == ".ps1") { PowerShellScript.Init(scriptPath); } } } if (Directory.Exists(ConfigFolder + "Scripts")) { foreach (string scriptPath in Directory.GetFiles(ConfigFolder + "Scripts")) { if (Path.GetExtension(scriptPath) == ".py") { PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); } else if (Path.GetExtension(scriptPath) == ".ps1") { PowerShellScript.Init(scriptPath); } } } }
public static void LoadScripts() { string[] jsLua = { ".lua", ".js" }; string[] startupScripts = Directory.GetFiles(Application.StartupPath + "\\Scripts"); foreach (var scriptPath in startupScripts) { if (jsLua.Contains(Path.GetExtension(scriptPath).ToLower())) { commandv("load-script", $"{scriptPath}"); } } foreach (var scriptPath in startupScripts) { if (Path.GetExtension(scriptPath) == ".py") { PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); } } foreach (var scriptPath in startupScripts) { if (Path.GetExtension(scriptPath) == ".ps1") { PowerShellScript.Init(scriptPath); } } if (Directory.Exists(ConfFolder + "Scripts")) { foreach (var scriptPath in Directory.GetFiles(ConfFolder + "Scripts")) { if (Path.GetExtension(scriptPath) == ".py") { PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); } else if (Path.GetExtension(scriptPath) == ".ps1") { PowerShellScript.Init(scriptPath); } } } }