LuaEnvironment.cpp 653 B

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