- First get Lua bit ops from: http://bitop.luajit.org/
- Extract it to 3rdParty/luabitop. Under 3rdParty in the moai-sdk source code you'll see a bunch of other lua extensions. We're just going to make bitop one of those.
- Add the source code to your solution or make file: Under the VS2010 solution I added a new folder: 'Libraries/luaext/luabit' and made sure it included the 'bit.c' file from the luabit source extracted above.
- Edit src/aku/AKU-luaext.h: Follow the pattern and add:
- Code: Select all
- AKU_API void AKUExtLoadLuabit();
- Provide the trivial implementation in src/aku/AKU-luaext.cpp, again following the existing pattern you'll see:
- Code: Select all
- extern "C" {
- // bit.c implements this
- extern int luaopen_bit ( lua_State *L );
- }
- void AKUExtLoadLuabit () {
- lua_State* state = AKUGetLuaState ();
- luaopen_bit( state );
- }
- Get the GLUTHost.cpp to call this code (search for GLUTHOST_USE_LUAEXT and you'll find the block of code that loads all the existing extensions):
- Code: Select all
- #ifdef GLUTHOST_USE_LUAEXT
- AKUExtLoadLuabit ();
- #endif
- Try it out. Under MOAI Lua code the 'bit' module is automatically available so you can do things like:
- Code: Select all
- flags = bit.bor(flags, MY_FLAG)


