Call only one specific function in a Lua script from c
<p>Is it possible to only call one specific function in a Lua script from C. Currently, I have a Lua script which calls a C function. Now, I need this C function to call just one Lua function from the mentioned script.</p>

<p>EDIT:
The C functions look like this:</p>

<pre><code>#include &lt;lua.h&gt;
#include &lt;lauxlib.h&gt; 
#include &lt;lualib.h&gt;


static double E1(double x) {

    double xint = x;
    double z;


    lua_State *L;
    L = luaL_newstate();

    luaL_openlibs(L);

    luaL_loadfile(L, "luascript.lua");

    lua_pcall(L, 0, 0, 0);

    lua_getglobal(L, "func");
    lua_pushnumber(L, x);

    lua_pcall(L, 1, 1, 0);

    z = lua_tonumber(L, -1);
    lua_pop(L, 1);

    lua_close(L);

    return z;
}

static int Ret(lua_State *L){

    double y = lua_tonumber(L, -1);

    lua_pushnumber(L, E1(y));

    return 1;
}

int luaopen_func2lua(lua_State *L){
    lua_register(
                    L,
                    "Ret",
                    Ret
                    );
    return 0;
}
</code></pre>

<p>The Lua script looks like this:</p>

<pre><code> require "func2lua"

 function func (x)
     -- some mathematical stuff
     return value
 end

 x = 23.1

 print(Ret(x)) -- Ret is the C function from the top c-file
</code></pre>