Skip to main content
gamedev.net
🔒 Locked

lua stack overflow

Started by huaner Jun 19, 2007 at 2:11 AM 0 replies 1.7k views
Original Post
huaner
huaner
Hi: my lua script is:

ForceInfo = {ForceStrength = 20000, ForceDirX = 1, ForceDirY = 0, ForceDirZ = 0}
function DecideForceInfo()
 curPosx, curPosz = GetCurrentPos()
 if(curPosx >= 0.0) then
     print("Stop Now")
     ForceInfo.ForceStrength = 0.0
 else
     print("Now position of x is" .. curPosx)
 end
end

i want to call script in the rendering loop; at same time i register the function of GetCurrentPos and then load lua file before rendering; the calling script codes are:

lua_getglobal(luaVM, "ForceInfo");

 DecideForceInfo();

 gForceStrength1 = getfield("ForceStrength");
 gForceDir.x = getfield("ForceDirX");//get the key value of table
 gForceDir.y = getfield("ForceDirY");
 gForceDir.z = getfield("ForceDirZ");

the relative script code are belown:

int GetCurrentPos(lua_State *L)
{
 lua_pushnumber(L, curpos.x);
 lua_pushnumber(L, curpos.z);

 /* return the number of results */
 return 2;
}

void DecideForceInfo()
{
 lua_getglobal(luaVM, "DecideForceInfo");
 lua_call(luaVM, 0, 0);
}

but the error information is:

stack traceback:
1: function 'GetCurrentPos' [c]
2: function \DecideForceInfo'

why? anybody help me? thank you very much!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.