From 8e10f89c4d82a1e55791cbc15e19bc486d9d42b9 Mon Sep 17 00:00:00 2001 From: Grossley <42724744+Grossley@users.noreply.github.com> Date: Sun, 20 Jun 2021 18:28:03 -0700 Subject: [PATCH] Add VariableFixer script to fix a bug that prevents the game from loading --- .../CommunityScripts/VariableFixer.csx | 29 +++++++++++++++++++ UndertaleModTool/UndertaleModTool.csproj | 3 ++ 2 files changed, 32 insertions(+) create mode 100644 UndertaleModTool/CommunityScripts/VariableFixer.csx diff --git a/UndertaleModTool/CommunityScripts/VariableFixer.csx b/UndertaleModTool/CommunityScripts/VariableFixer.csx new file mode 100644 index 000000000..6c3bae2cc --- /dev/null +++ b/UndertaleModTool/CommunityScripts/VariableFixer.csx @@ -0,0 +1,29 @@ +// Made by Creepersbane +ScriptMessage(@"This script will most likely fix data files with the following symptoms: + +If, after loading the data file after code editing, any of the following occur: + +No window appears at all +""Out of memory!"" error appears while loading +No "".gamelog.txt"" is produced +The "".gamelog.txt"" is produced but appears to fail after Steam initialization. +The game window appears but is frozen indefinitely +"); +Data.GeneralInfo.DisableDebugger = true; +int globalNum = 0; +int selfNum = 0; +foreach(var vari in Data.Variables) +{ + if (vari.InstanceType == UndertaleInstruction.InstanceType.Global) + { + vari.VarID = globalNum++; + } + else if ((vari.InstanceType == UndertaleInstruction.InstanceType.Self) && (vari.VarID >= 0)) + { + vari.VarID = selfNum++; + } +} +Data.VarCount1 = (uint)globalNum; +Data.VarCount2 = (uint)selfNum; + +ScriptMessage(@"Complete, please save and run the game now to apply and test your changes."); \ No newline at end of file diff --git a/UndertaleModTool/UndertaleModTool.csproj b/UndertaleModTool/UndertaleModTool.csproj index 9fa32d58a..4bda31e1f 100644 --- a/UndertaleModTool/UndertaleModTool.csproj +++ b/UndertaleModTool/UndertaleModTool.csproj @@ -47,6 +47,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest true