using System.Text; using System; using System.IO; using System.Threading; using System.Threading.Tasks; using UndertaleModLib.Util;
EnsureDataLoaded();
if (Data.ToolInfo.ProfileMode) { ScriptMessage("This script will not modify your existing edited GML code registered in your profile. Please use GML editing for text editing, or a script like FindAndReplace, for editing strings within these code entries."); } else { if (!(ScriptQuestion("This script will recompile all code entries in your profile (if they exist) to the default decompiled output. Continue?"))) return; foreach (UndertaleCode c in Data.Code) NukeProfileGML(c.Name.Content); }
string importFolder = PromptChooseDirectory(); if (importFolder is null) throw new ScriptException("The import folder was not set.");
// Overwrite Check One string stringsPath = Path.Combine(importFolder, "strings.txt"); if (!File.Exists(stringsPath)) { ScriptError("No 'strings.txt' file exists!", "Error"); return; }
var file = File.ReadAllText(stringsPath); file=file.Replace("\r\n\r\n", "\r\n"); file=file.Replace("\r\r", "\r"); file=file.Replace("\n\n", "\n"); var file_edited=File.CreateText(stringsPath.Replace("strings.txt", "strings_edited.txt")); file_edited.Write(file); file_edited.Close();
using (StreamReader reader = new StreamReader(stringsPath.Replace("strings.txt", "strings_edited.txt"))) { foreach (var str in Data.Strings) { if (str.Content.Contains("\n") || str.Content.Contains("\r")) continue; if (str.Content.StartsWith("* ")) str.Content=reader.ReadLine(); } }
本来天机写的是在str.Content=reader.ReadLine()之后再单独执行一次reader.ReadLine() but don’t know why, it just won’t work, and it will break data.win 所以我就用了一个非常简单粗暴且弱智的方法 直接修改原来的txt保存为另一个txt 然后读取保存出来的txt 不管它有多弱智,it just works 能跑就行 嗯