lua_AnimationController.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_AnimationController.h"
  4. #include "AnimationController.h"
  5. #include "Base.h"
  6. #include "Curve.h"
  7. #include "Game.h"
  8. namespace gameplay
  9. {
  10. void luaRegister_AnimationController()
  11. {
  12. const luaL_Reg lua_members[] =
  13. {
  14. {"stopAllAnimations", lua_AnimationController_stopAllAnimations},
  15. {NULL, NULL}
  16. };
  17. const luaL_Reg* lua_statics = NULL;
  18. std::vector<std::string> scopePath;
  19. ScriptUtil::registerClass("AnimationController", lua_members, NULL, NULL, lua_statics, scopePath);
  20. }
  21. static AnimationController* getInstance(lua_State* state)
  22. {
  23. void* userdata = luaL_checkudata(state, 1, "AnimationController");
  24. luaL_argcheck(state, userdata != NULL, 1, "'AnimationController' expected.");
  25. return (AnimationController*)((ScriptUtil::LuaObject*)userdata)->instance;
  26. }
  27. int lua_AnimationController_stopAllAnimations(lua_State* state)
  28. {
  29. // Get the number of parameters.
  30. int paramCount = lua_gettop(state);
  31. // Attempt to match the parameters to a valid binding.
  32. switch (paramCount)
  33. {
  34. case 1:
  35. {
  36. if ((lua_type(state, 1) == LUA_TUSERDATA))
  37. {
  38. AnimationController* instance = getInstance(state);
  39. instance->stopAllAnimations();
  40. return 0;
  41. }
  42. lua_pushstring(state, "lua_AnimationController_stopAllAnimations - Failed to match the given parameters to a valid function signature.");
  43. lua_error(state);
  44. break;
  45. }
  46. default:
  47. {
  48. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  49. lua_error(state);
  50. break;
  51. }
  52. }
  53. return 0;
  54. }
  55. }