2
0

LuaEnvironment.cpp 673 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <cassert>
  2. #include "LuaEnvironment.h"
  3. namespace crown
  4. {
  5. LuaEnvironment::LuaEnvironment(lua_State* L) :
  6. m_state(L)
  7. {
  8. }
  9. //-----------------------------------------------------------
  10. void LuaEnvironment::load_module_function(const char* module, const char* name, const lua_CFunction func)
  11. {
  12. luaL_Reg entry[2];
  13. entry[0].name = name;
  14. entry[0].func = func;
  15. entry[1].name = NULL;
  16. entry[1].func = NULL;
  17. luaL_register(m_state, module, entry);
  18. }
  19. extern "C"
  20. {
  21. int luaopen_libcrownlua(lua_State* L)
  22. {
  23. LuaEnvironment env(L);
  24. load_vec2(env);
  25. load_vec3(env);
  26. load_mouse(env);
  27. load_keyboard(env);
  28. load_accelerometer(env);
  29. }
  30. }
  31. } // namespace crown