lua_getglobal(L, "texio"); /* table to index */
lua_getfield(L, -1, "write_nl"); /* function to be called */
lua_remove(L, -2); /* remove table texio from stack */
lua_pushstring(L, "Hello, world!"); /* push first argument to stack */
lua_call(L, 1, 0); */ call function with 1 argument and without result */
This is the breakdown of the function you did not understand. So how does `lua_call` know which function to call? Because given the stack pointer it calculates where to go for a function with 1 argument and without result and then performs the call.