[LUA] Debugging

Recommended Posts

I have only a very basic LUA knowledge, I use it merely as something slightly above configuration file.

I have this problem, I run a LUA file (luaL_loadfile() then lua_pcall()) and when there is some syntax error (like misspelled function name) I only get a generic "communication error" without mentioning the line of the error (which alone would solve the problem for me). I tried to google the solution but could not really find anything useful... Which is weird

So, how to make it return the line of the error in LUA script?

Share on other sites
std::string errorMsg = "";

if (luaL_dofile(L, fullFilename.c_str()))
{
errorMsg = lua_tostring(L, -1);
}

Share on other sites
12 minutes ago, VoxycDev said:

std::string errorMsg = "";

if (luaL_dofile(L, fullFilename.c_str()))
{
errorMsg = lua_tostring(L, -1);﻿
}

... LOL, that was trivial indeed I wish I asked a few months ago

Big thanks VoxycDev!

Create an account

Register a new account

• 17
• 14
• 10
• 10
• 12