- Joined
- Jun 26, 2020
- Messages
- 1,924
I don't know if this was actually found, but there is a way to get the stack trace in W3 Lua, just using the error function, because is the unique function that can tell us what function called it and the function that called this and so on, so I did something like this:
Why from start 4?, because the first will refer to the xpcall function; the second, the GetStackTrace function; and probably you will add this right before an error will happen, so it will display what would be the third position.
This is the result:
Is not very clean, but is the better solution I can think. Pls give feedback.
Lua:
function GetStackTrace()
xpcall(error, print, "Fourth", 7)
xpcall(error, print, "Third", 6)
xpcall(error, print, "Second", 5)
xpcall(error, print, "First", 4)
end
This is the result:
Is not very clean, but is the better solution I can think. Pls give feedback.
Last edited: