[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lua_pcall error
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Tue, 26 Sep 2006 22:50:08 -0700
Hi,
I'm trying to figure out how to call functions with no arguments or
return values from C. I have a function draw:
function draw()
vert = {-1, 0, 0}
gl.Begin("LINES")
gl.Color(1, 1, 0)
gl.Vertex(vert)
vert[1], vert[2] = vert[2], vert[1]
print(vert[1] .. " " .. vert[2] .. " ".. vert[3])
gl.Vertex(vert)
gl.Vertex(0.5, 0, 1)
gl.Vertex(-0.5, 0, 1)
gl.End()
end
and am trying to call this from C using the following:
err = luaL_loadstring(x->lua, *(x->texthandle));
lua_getglobal(x->lua, "draw");
err = lua_pcall(x->lua, 0, 0, 0);
This gives me the error "attempt to call a nil value". However, when I do this:
err = luaL_loadstring(x->lua, *(x->texthandle));
err = lua_pcall(x->lua, 0, LUA_MULTRET, 0);
and have the code in the draw function in global scope things work.
I've been knocking my head against the computer screen trying to
figure this out. I know it's basic, but does anyone understand what's
going on here?
thanks,
wes