The BSDCan 2011 slides on BSDLUA are here: {{ivanvoras/bsdlua/bsdlua.pdf?linkonly|bsdlua.pdf}} and also here: http://people.freebsd.org/~ivoras/slides/bsdlua2011.pdf . The current (may be temporary) Mercurial (hg) repository for BSDLUA is available at http://cosmos.boldlygoingnowhere.org:81/~ivoras/hg/bsdlua . You can make a local clone of the repository with: hg clone http://cosmos.boldlygoingnowhere.org:81/~ivoras/hg/bsdlua Please send patches via ''%%hg export%%''! ===== Tutorial for embedders ===== Please read the following documentation: * http://www.lua.org/ - The main Lua site * http://pgl.yoyo.org/luai/i/3.7+Functions+and+Types - C functions and types used to access Lua from C * http://www.lua.org/manual/5.1/#index - all else on Lua * http://lua-users.org/wiki/LuaDirectory - some Lua Wiki resources * http://www.codeproject.com/KB/cpp/luaincpp.aspx - Another tutorial on embedding The newest version of this script is committed in the BSDLUA hg repository in the ''%%bsdlua/tests/scripting%%'' directory. An example program (note that this program and its Makefile require that the BSDLUA is installed, i.e. that the ''%%make install%%'' target was executed): #include #include #include #include #include #include lua_State *L; static int greeting(lua_State *L) { /* This function accepts one string argument and returns no values */ int nargs = lua_gettop(L); const char *arg; assert(nargs == 1); arg = lua_tostring(L, 1); printf("Hello from C: %s\n", arg); /* lua_pushstring(L, "blah blah blah"); */ /* if the above line were uncommented, the function would return "1" */ return 0; } int main() { L = lua_open(); luaL_openlibs(L); luaL_dostring(L, "print(\"Hello from lua\")"); lua_register(L, "greeting", greeting); luaL_dostring(L, "greeting(\"cromulent\")"); /* Call BSDLUA */ luaL_dostring(L, "print(\"My PID is: \" .. posix.getpid())"); } Makefile: all: luainc clean: rm -f *.o *.core luainc luainc: luainc.o gcc -o luainc luainc.o -lbsdlua -lm -lcurses -lpanel luainc.o: luainc.c gcc -O2 -o luainc.o -c luainc.c