lua function argument expected near <eof> <p>I try to use lua in a C++ project. For lua executing I write this:</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;lua.hpp&gt; ... luaEngine = luaL_newstate(); luaL_openlibs(luaEngine); register_results(luaEngine); // For register c++ object in the LUA script as metatable lua_pushstring(luaEngine, resultsId.c_str()); lua_setglobal(luaEngine, "resultsId"); lua_pushboolean(luaEngine, needReloadModel); lua_setglobal(luaEngine, "needReload"); ... e = luaL_loadbuffer(luaEngine, script.c_str(), script.size(), NULL); if(e != 0) // error message e = lua_pcall(luaEngine, 0, 1, 0); if(e != 0) // error message ... lua_close(luaEngine); </code></pre> <p>And the lua script:</p> <pre class="lang-lua prettyprint-override"><code>local Res = ResUpdateLUA(resultsId) if current_result == "Normal" or current_result=='-' then status = 'E' else status = 'O' end needReload = Res:setShowAnalyte('2320', status) </code></pre> <p>That didn't work and I've got error message:</p> <blockquote> <pre class="lang-none prettyprint-override"><code>[string "?"]:7: function arguments expected near &lt;eof&gt; </code></pre> </blockquote> <p>But when I add</p> <pre class="lang-lua prettyprint-override"><code>print(needReload) </code></pre> <p>at the end of the lua script it works nice. What am I doing wrong?</p>