🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

[LUA] Debugging

Started by
2 comments, last by Acharis 5 years, 2 months ago

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?
 

 

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

Advertisement

std::string errorMsg = "";

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

 

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 :D

Big thanks VoxycDev!

 

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

This topic is closed to new replies.

Advertisement