lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi everyone! I originally posted this to the forum but I was told I'd be
more likely to get help here, so here I am.


I'm trying to modify an existing game engine by adding Lua support. This
is the first real Lua project I've ever done and I'm not exactly a C
expert either, but I'm pretty sure I've gone by the book here.

I started having problems with the Lua integration as soon as I moved
everything to its own file, so I took that file somewhere else and wrote
some simple code to test that file. 

Here is the file, lua.c, which I was trying to add to the game engine
(with game-engine specific components commented out and replaced with OS
shell calls.)
http://pastebin.com/m1c949623

Here is the file which I wrote in order to test lua.c:
http://pastebin.com/m1068b850

Here is the lua script I'm using:
http://pastebin.com/mbdce379

Here is the command-line output of me compiling the program, running it,
and a gdb session as well. 
http://pastebin.com/m50429f96


Essentially, I've got two major functions in lua.c. I have lua_initVM
which sets up the lua_State instance, loads the script into it, and
calls the "init" function from the script. That's working fine. Then I
have the lua_frameVM function which is simply supposed to call the
"frame" function from the script. However, ANY operation on my lua_State
instance which occurs outside the lua_initVM function is causing a
segfault. Even though the lua_State instance is declared as a global.



What am I doing wrong here?




Thanks!
-Max.