Skip to content

Commit

Permalink
Allow wesnoth.dofile to forward arbitrary arguments to the file's "..."
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed May 3, 2017
1 parent efb0fe0 commit 37c0cca
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/scripting/lua_kernel_base.cpp
Expand Up @@ -615,11 +615,13 @@ void lua_kernel_base::interactive_run(char const * prog) {
*/
int lua_kernel_base::intf_dofile(lua_State* L)
{
lua_rotate(L, 1, -1);
if (lua_fileops::load_file(L) != 1) return 0;
//^ should end with the file contents loaded on the stack. actually it will call lua_error otherwise, the return 0 is redundant.

error_handler eh = std::bind(&lua_kernel_base::log_error, this, _1, _2 );
this->protected_call(0, LUA_MULTRET, eh);
lua_rotate(L, 1, 1);
this->protected_call(lua_gettop(L) - 1, LUA_MULTRET, eh);
return lua_gettop(L);
}

Expand Down

0 comments on commit 37c0cca

Please sign in to comment.