neolithos / neolua

A Lua implementation for the Dynamic Language Runtime (DLR).
https://neolua.codeplex.com/
Apache License 2.0
472 stars 76 forks source link

Stacktrace Lua line number. #156

Closed EvaisaDev closed 1 year ago

EvaisaDev commented 2 years ago

Is there any way to print the line number of a Lua file where a error occurred? I tried using CompileChunk with the TraceLineDebugger like so: CompileChunk(ScriptFilePath, new LuaCompileOptions() { DebugEngine = new LuaTraceLineDebugger() }); However that just gives me the stacktrace to the C# line where the script was compiled using CompileChunk. What I want is the Lua line number where the error happened.

I am working in .net 6.0 (so using 5.0 build)

neolithos commented 2 years ago

This should work.

https://github.com/neolithos/neolua/blob/3c02bc5eeda060cdd9cb7cba2138b38fff33d84f/ExtTest/StartEx.cs#L36-L47

EvaisaDev commented 2 years ago

This should work.

https://github.com/neolithos/neolua/blob/3c02bc5eeda060cdd9cb7cba2138b38fff33d84f/ExtTest/StartEx.cs#L36-L47

LuaStackTraceDebugger is not available on .net 6.0, however I already got it working using a bunch of workarounds. I am on vacation right now so I cannot post my solution.