Ich habe einen Lua-Interpreter, dass, wenn ich einen Syntaxfehler in meinem Code mache, die zurückgegebene Fehlermeldung einfach attempted to call a string value
statt einer sinnvollen Fehlermeldung ist. Zum Beispiel, wenn ich diesen lua-Code ausführen:Beschreibende Fehlermeldungen für Lua-Syntaxfehler
for a= 1,10
print(a)
end
Anstatt eine sinnvolle 'do' expected near 'print'
und eine Zeilennummer Rückkehr wird es nur die Fehler zurück attempted to call a string value
.
Meine C++ Code ist folgende:
void LuaInterpreter::run(std::string script) {
luaL_openlibs(m_mainState);
// Adds all functions for calling in lua code
addFunctions(m_mainState);
// Loading the script string into lua
luaL_loadstring(m_mainState, script.c_str());
// Calls the script
int error =lua_pcall(m_mainState, 0, 0, 0);
if (error) {
std::cout << lua_tostring(m_mainState, -1) << std::endl;
lua_pop(m_mainState, 1);
}
}
Vielen Dank im Voraus!