Lua Scripting

0 views
Skip to first unread message

inferno

unread,
Sep 2, 2008, 6:59:24 PM9/2/08
to Falling Sand Games Development
The basic steps:

1. Set up Lua for your compiler (I suggest Dev-C++ because it is very
easy to get it via devpak).

2. Set up an init function. lua_State *L = lua_open(); and
luaL_openlibs(L);, followed by lua_register(L,int func(lua_State *L));
to connect Lua functions to C functions. Then use
luaL_dofile("filename"); to run the default config file.

More advanced management:

Always (ALWAYS) use lua_checkstack(L,values) before manipulating Lua
at all. Also, I suggest that, at the end of each game loop, use
lua_pop(L,values) with a lua_checkstack() to make sure you have Lua
stackspace. Example:

if (lua_checkstack(L,10) == 0)
lua_pop(L,10);

More to come.

madk

unread,
Sep 2, 2008, 8:07:03 PM9/2/08
to Falling Sand Games Development
Thanks for this tutorial. I could use it.
Reply all
Reply to author
Forward
0 new messages