diff --git a/src/MoonSharp.Interpreter/TtsDebugger.cs b/src/MoonSharp.Interpreter/TtsDebugger.cs index fd52e2ad..1ec25382 100644 --- a/src/MoonSharp.Interpreter/TtsDebugger.cs +++ b/src/MoonSharp.Interpreter/TtsDebugger.cs @@ -215,7 +215,13 @@ public static void OnStringDone(Script script) private static string SourceCodeToTempPath(SourceCode sourceCode) { - var scriptName = scriptNames[sourceCode.OwnerScript]; + string scriptName; + + if (!scriptNames.TryGetValue(sourceCode.OwnerScript, out scriptName)) + { + scriptName = "unknown"; + } + var sourceName = (scriptName == sourceCode.Name ? scriptName : $"{scriptName}_{sourceCode.Name}").Replace(Path.DirectorySeparatorChar, '_'); var path = Path.Combine(tempPath, sourceName + ".ttslua");