lua_AnimationTarget.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_AnimationTarget.h"
  4. #include "Animation.h"
  5. #include "AnimationTarget.h"
  6. #include "Base.h"
  7. #include "Game.h"
  8. #include "Node.h"
  9. #include "lua_CurveInterpolationType.h"
  10. namespace gameplay
  11. {
  12. void luaRegister_AnimationTarget()
  13. {
  14. const luaL_Reg lua_members[] =
  15. {
  16. {"createAnimation", lua_AnimationTarget_createAnimation},
  17. {"createAnimationFromBy", lua_AnimationTarget_createAnimationFromBy},
  18. {"createAnimationFromTo", lua_AnimationTarget_createAnimationFromTo},
  19. {"destroyAnimation", lua_AnimationTarget_destroyAnimation},
  20. {"getAnimation", lua_AnimationTarget_getAnimation},
  21. {"getAnimationPropertyComponentCount", lua_AnimationTarget_getAnimationPropertyComponentCount},
  22. {"getAnimationPropertyValue", lua_AnimationTarget_getAnimationPropertyValue},
  23. {"setAnimationPropertyValue", lua_AnimationTarget_setAnimationPropertyValue},
  24. {NULL, NULL}
  25. };
  26. const luaL_Reg* lua_statics = NULL;
  27. std::vector<std::string> scopePath;
  28. ScriptUtil::registerClass("AnimationTarget", lua_members, NULL, NULL, lua_statics, scopePath);
  29. }
  30. static AnimationTarget* getInstance(lua_State* state)
  31. {
  32. void* userdata = luaL_checkudata(state, 1, "AnimationTarget");
  33. luaL_argcheck(state, userdata != NULL, 1, "'AnimationTarget' expected.");
  34. return (AnimationTarget*)((ScriptUtil::LuaObject*)userdata)->instance;
  35. }
  36. int lua_AnimationTarget_createAnimation(lua_State* state)
  37. {
  38. // Get the number of parameters.
  39. int paramCount = lua_gettop(state);
  40. // Attempt to match the parameters to a valid binding.
  41. switch (paramCount)
  42. {
  43. case 3:
  44. {
  45. do
  46. {
  47. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  48. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  49. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
  50. {
  51. // Get parameter 1 off the stack.
  52. ScriptUtil::LuaArray<const char> param1 = ScriptUtil::getString(2, false);
  53. // Get parameter 2 off the stack.
  54. ScriptUtil::LuaArray<const char> param2 = ScriptUtil::getString(3, false);
  55. AnimationTarget* instance = getInstance(state);
  56. void* returnPtr = (void*)instance->createAnimation(param1, param2);
  57. if (returnPtr)
  58. {
  59. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  60. object->instance = returnPtr;
  61. object->owns = false;
  62. luaL_getmetatable(state, "Animation");
  63. lua_setmetatable(state, -2);
  64. }
  65. else
  66. {
  67. lua_pushnil(state);
  68. }
  69. return 1;
  70. }
  71. } while (0);
  72. do
  73. {
  74. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  75. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  76. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  77. {
  78. // Get parameter 1 off the stack.
  79. ScriptUtil::LuaArray<const char> param1 = ScriptUtil::getString(2, false);
  80. // Get parameter 2 off the stack.
  81. bool param2Valid;
  82. ScriptUtil::LuaArray<Properties> param2 = ScriptUtil::getObjectPointer<Properties>(3, "Properties", false, &param2Valid);
  83. if (!param2Valid)
  84. break;
  85. AnimationTarget* instance = getInstance(state);
  86. void* returnPtr = (void*)instance->createAnimation(param1, param2);
  87. if (returnPtr)
  88. {
  89. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  90. object->instance = returnPtr;
  91. object->owns = false;
  92. luaL_getmetatable(state, "Animation");
  93. lua_setmetatable(state, -2);
  94. }
  95. else
  96. {
  97. lua_pushnil(state);
  98. }
  99. return 1;
  100. }
  101. } while (0);
  102. lua_pushstring(state, "lua_AnimationTarget_createAnimation - Failed to match the given parameters to a valid function signature.");
  103. lua_error(state);
  104. break;
  105. }
  106. case 7:
  107. {
  108. do
  109. {
  110. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  111. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  112. lua_type(state, 3) == LUA_TNUMBER &&
  113. lua_type(state, 4) == LUA_TNUMBER &&
  114. (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
  115. (lua_type(state, 6) == LUA_TTABLE || lua_type(state, 6) == LUA_TLIGHTUSERDATA) &&
  116. (lua_type(state, 7) == LUA_TSTRING || lua_type(state, 7) == LUA_TNIL))
  117. {
  118. // Get parameter 1 off the stack.
  119. ScriptUtil::LuaArray<const char> param1 = ScriptUtil::getString(2, false);
  120. // Get parameter 2 off the stack.
  121. int param2 = (int)luaL_checkint(state, 3);
  122. // Get parameter 3 off the stack.
  123. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  124. // Get parameter 4 off the stack.
  125. ScriptUtil::LuaArray<unsigned int> param4 = ScriptUtil::getUnsignedIntPointer(5);
  126. // Get parameter 5 off the stack.
  127. ScriptUtil::LuaArray<float> param5 = ScriptUtil::getFloatPointer(6);
  128. // Get parameter 6 off the stack.
  129. Curve::InterpolationType param6 = (Curve::InterpolationType)lua_enumFromString_CurveInterpolationType(luaL_checkstring(state, 7));
  130. AnimationTarget* instance = getInstance(state);
  131. void* returnPtr = (void*)instance->createAnimation(param1, param2, param3, param4, param5, param6);
  132. if (returnPtr)
  133. {
  134. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  135. object->instance = returnPtr;
  136. object->owns = false;
  137. luaL_getmetatable(state, "Animation");
  138. lua_setmetatable(state, -2);
  139. }
  140. else
  141. {
  142. lua_pushnil(state);
  143. }
  144. return 1;
  145. }
  146. } while (0);
  147. lua_pushstring(state, "lua_AnimationTarget_createAnimation - Failed to match the given parameters to a valid function signature.");
  148. lua_error(state);
  149. break;
  150. }
  151. case 9:
  152. {
  153. do
  154. {
  155. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  156. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  157. lua_type(state, 3) == LUA_TNUMBER &&
  158. lua_type(state, 4) == LUA_TNUMBER &&
  159. (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
  160. (lua_type(state, 6) == LUA_TTABLE || lua_type(state, 6) == LUA_TLIGHTUSERDATA) &&
  161. (lua_type(state, 7) == LUA_TTABLE || lua_type(state, 7) == LUA_TLIGHTUSERDATA) &&
  162. (lua_type(state, 8) == LUA_TTABLE || lua_type(state, 8) == LUA_TLIGHTUSERDATA) &&
  163. (lua_type(state, 9) == LUA_TSTRING || lua_type(state, 9) == LUA_TNIL))
  164. {
  165. // Get parameter 1 off the stack.
  166. ScriptUtil::LuaArray<const char> param1 = ScriptUtil::getString(2, false);
  167. // Get parameter 2 off the stack.
  168. int param2 = (int)luaL_checkint(state, 3);
  169. // Get parameter 3 off the stack.
  170. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  171. // Get parameter 4 off the stack.
  172. ScriptUtil::LuaArray<unsigned int> param4 = ScriptUtil::getUnsignedIntPointer(5);
  173. // Get parameter 5 off the stack.
  174. ScriptUtil::LuaArray<float> param5 = ScriptUtil::getFloatPointer(6);
  175. // Get parameter 6 off the stack.
  176. ScriptUtil::LuaArray<float> param6 = ScriptUtil::getFloatPointer(7);
  177. // Get parameter 7 off the stack.
  178. ScriptUtil::LuaArray<float> param7 = ScriptUtil::getFloatPointer(8);
  179. // Get parameter 8 off the stack.
  180. Curve::InterpolationType param8 = (Curve::InterpolationType)lua_enumFromString_CurveInterpolationType(luaL_checkstring(state, 9));
  181. AnimationTarget* instance = getInstance(state);
  182. void* returnPtr = (void*)instance->createAnimation(param1, param2, param3, param4, param5, param6, param7, param8);
  183. if (returnPtr)
  184. {
  185. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  186. object->instance = returnPtr;
  187. object->owns = false;
  188. luaL_getmetatable(state, "Animation");
  189. lua_setmetatable(state, -2);
  190. }
  191. else
  192. {
  193. lua_pushnil(state);
  194. }
  195. return 1;
  196. }
  197. } while (0);
  198. lua_pushstring(state, "lua_AnimationTarget_createAnimation - Failed to match the given parameters to a valid function signature.");
  199. lua_error(state);
  200. break;
  201. }
  202. default:
  203. {
  204. lua_pushstring(state, "Invalid number of parameters (expected 3, 7 or 9).");
  205. lua_error(state);
  206. break;
  207. }
  208. }
  209. return 0;
  210. }
  211. int lua_AnimationTarget_createAnimationFromBy(lua_State* state)
  212. {
  213. // Get the number of parameters.
  214. int paramCount = lua_gettop(state);
  215. // Attempt to match the parameters to a valid binding.
  216. switch (paramCount)
  217. {
  218. case 7:
  219. {
  220. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  221. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  222. lua_type(state, 3) == LUA_TNUMBER &&
  223. (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) &&
  224. (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
  225. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
  226. lua_type(state, 7) == LUA_TNUMBER)
  227. {
  228. // Get parameter 1 off the stack.
  229. ScriptUtil::LuaArray<const char> param1 = ScriptUtil::getString(2, false);
  230. // Get parameter 2 off the stack.
  231. int param2 = (int)luaL_checkint(state, 3);
  232. // Get parameter 3 off the stack.
  233. ScriptUtil::LuaArray<float> param3 = ScriptUtil::getFloatPointer(4);
  234. // Get parameter 4 off the stack.
  235. ScriptUtil::LuaArray<float> param4 = ScriptUtil::getFloatPointer(5);
  236. // Get parameter 5 off the stack.
  237. Curve::InterpolationType param5 = (Curve::InterpolationType)lua_enumFromString_CurveInterpolationType(luaL_checkstring(state, 6));
  238. // Get parameter 6 off the stack.
  239. unsigned long param6 = (unsigned long)luaL_checkunsigned(state, 7);
  240. AnimationTarget* instance = getInstance(state);
  241. void* returnPtr = (void*)instance->createAnimationFromBy(param1, param2, param3, param4, param5, param6);
  242. if (returnPtr)
  243. {
  244. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  245. object->instance = returnPtr;
  246. object->owns = false;
  247. luaL_getmetatable(state, "Animation");
  248. lua_setmetatable(state, -2);
  249. }
  250. else
  251. {
  252. lua_pushnil(state);
  253. }
  254. return 1;
  255. }
  256. lua_pushstring(state, "lua_AnimationTarget_createAnimationFromBy - Failed to match the given parameters to a valid function signature.");
  257. lua_error(state);
  258. break;
  259. }
  260. default:
  261. {
  262. lua_pushstring(state, "Invalid number of parameters (expected 7).");
  263. lua_error(state);
  264. break;
  265. }
  266. }
  267. return 0;
  268. }
  269. int lua_AnimationTarget_createAnimationFromTo(lua_State* state)
  270. {
  271. // Get the number of parameters.
  272. int paramCount = lua_gettop(state);
  273. // Attempt to match the parameters to a valid binding.
  274. switch (paramCount)
  275. {
  276. case 7:
  277. {
  278. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  279. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  280. lua_type(state, 3) == LUA_TNUMBER &&
  281. (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) &&
  282. (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
  283. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
  284. lua_type(state, 7) == LUA_TNUMBER)
  285. {
  286. // Get parameter 1 off the stack.
  287. ScriptUtil::LuaArray<const char> param1 = ScriptUtil::getString(2, false);
  288. // Get parameter 2 off the stack.
  289. int param2 = (int)luaL_checkint(state, 3);
  290. // Get parameter 3 off the stack.
  291. ScriptUtil::LuaArray<float> param3 = ScriptUtil::getFloatPointer(4);
  292. // Get parameter 4 off the stack.
  293. ScriptUtil::LuaArray<float> param4 = ScriptUtil::getFloatPointer(5);
  294. // Get parameter 5 off the stack.
  295. Curve::InterpolationType param5 = (Curve::InterpolationType)lua_enumFromString_CurveInterpolationType(luaL_checkstring(state, 6));
  296. // Get parameter 6 off the stack.
  297. unsigned long param6 = (unsigned long)luaL_checkunsigned(state, 7);
  298. AnimationTarget* instance = getInstance(state);
  299. void* returnPtr = (void*)instance->createAnimationFromTo(param1, param2, param3, param4, param5, param6);
  300. if (returnPtr)
  301. {
  302. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  303. object->instance = returnPtr;
  304. object->owns = false;
  305. luaL_getmetatable(state, "Animation");
  306. lua_setmetatable(state, -2);
  307. }
  308. else
  309. {
  310. lua_pushnil(state);
  311. }
  312. return 1;
  313. }
  314. lua_pushstring(state, "lua_AnimationTarget_createAnimationFromTo - Failed to match the given parameters to a valid function signature.");
  315. lua_error(state);
  316. break;
  317. }
  318. default:
  319. {
  320. lua_pushstring(state, "Invalid number of parameters (expected 7).");
  321. lua_error(state);
  322. break;
  323. }
  324. }
  325. return 0;
  326. }
  327. int lua_AnimationTarget_destroyAnimation(lua_State* state)
  328. {
  329. // Get the number of parameters.
  330. int paramCount = lua_gettop(state);
  331. // Attempt to match the parameters to a valid binding.
  332. switch (paramCount)
  333. {
  334. case 1:
  335. {
  336. if ((lua_type(state, 1) == LUA_TUSERDATA))
  337. {
  338. AnimationTarget* instance = getInstance(state);
  339. instance->destroyAnimation();
  340. return 0;
  341. }
  342. lua_pushstring(state, "lua_AnimationTarget_destroyAnimation - Failed to match the given parameters to a valid function signature.");
  343. lua_error(state);
  344. break;
  345. }
  346. case 2:
  347. {
  348. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  349. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  350. {
  351. // Get parameter 1 off the stack.
  352. ScriptUtil::LuaArray<const char> param1 = ScriptUtil::getString(2, false);
  353. AnimationTarget* instance = getInstance(state);
  354. instance->destroyAnimation(param1);
  355. return 0;
  356. }
  357. lua_pushstring(state, "lua_AnimationTarget_destroyAnimation - Failed to match the given parameters to a valid function signature.");
  358. lua_error(state);
  359. break;
  360. }
  361. default:
  362. {
  363. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  364. lua_error(state);
  365. break;
  366. }
  367. }
  368. return 0;
  369. }
  370. int lua_AnimationTarget_getAnimation(lua_State* state)
  371. {
  372. // Get the number of parameters.
  373. int paramCount = lua_gettop(state);
  374. // Attempt to match the parameters to a valid binding.
  375. switch (paramCount)
  376. {
  377. case 1:
  378. {
  379. if ((lua_type(state, 1) == LUA_TUSERDATA))
  380. {
  381. AnimationTarget* instance = getInstance(state);
  382. void* returnPtr = (void*)instance->getAnimation();
  383. if (returnPtr)
  384. {
  385. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  386. object->instance = returnPtr;
  387. object->owns = false;
  388. luaL_getmetatable(state, "Animation");
  389. lua_setmetatable(state, -2);
  390. }
  391. else
  392. {
  393. lua_pushnil(state);
  394. }
  395. return 1;
  396. }
  397. lua_pushstring(state, "lua_AnimationTarget_getAnimation - Failed to match the given parameters to a valid function signature.");
  398. lua_error(state);
  399. break;
  400. }
  401. case 2:
  402. {
  403. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  404. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  405. {
  406. // Get parameter 1 off the stack.
  407. ScriptUtil::LuaArray<const char> param1 = ScriptUtil::getString(2, false);
  408. AnimationTarget* instance = getInstance(state);
  409. void* returnPtr = (void*)instance->getAnimation(param1);
  410. if (returnPtr)
  411. {
  412. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  413. object->instance = returnPtr;
  414. object->owns = false;
  415. luaL_getmetatable(state, "Animation");
  416. lua_setmetatable(state, -2);
  417. }
  418. else
  419. {
  420. lua_pushnil(state);
  421. }
  422. return 1;
  423. }
  424. lua_pushstring(state, "lua_AnimationTarget_getAnimation - Failed to match the given parameters to a valid function signature.");
  425. lua_error(state);
  426. break;
  427. }
  428. default:
  429. {
  430. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  431. lua_error(state);
  432. break;
  433. }
  434. }
  435. return 0;
  436. }
  437. int lua_AnimationTarget_getAnimationPropertyComponentCount(lua_State* state)
  438. {
  439. // Get the number of parameters.
  440. int paramCount = lua_gettop(state);
  441. // Attempt to match the parameters to a valid binding.
  442. switch (paramCount)
  443. {
  444. case 2:
  445. {
  446. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  447. lua_type(state, 2) == LUA_TNUMBER)
  448. {
  449. // Get parameter 1 off the stack.
  450. int param1 = (int)luaL_checkint(state, 2);
  451. AnimationTarget* instance = getInstance(state);
  452. unsigned int result = instance->getAnimationPropertyComponentCount(param1);
  453. // Push the return value onto the stack.
  454. lua_pushunsigned(state, result);
  455. return 1;
  456. }
  457. lua_pushstring(state, "lua_AnimationTarget_getAnimationPropertyComponentCount - Failed to match the given parameters to a valid function signature.");
  458. lua_error(state);
  459. break;
  460. }
  461. default:
  462. {
  463. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  464. lua_error(state);
  465. break;
  466. }
  467. }
  468. return 0;
  469. }
  470. int lua_AnimationTarget_getAnimationPropertyValue(lua_State* state)
  471. {
  472. // Get the number of parameters.
  473. int paramCount = lua_gettop(state);
  474. // Attempt to match the parameters to a valid binding.
  475. switch (paramCount)
  476. {
  477. case 3:
  478. {
  479. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  480. lua_type(state, 2) == LUA_TNUMBER &&
  481. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  482. {
  483. // Get parameter 1 off the stack.
  484. int param1 = (int)luaL_checkint(state, 2);
  485. // Get parameter 2 off the stack.
  486. bool param2Valid;
  487. ScriptUtil::LuaArray<AnimationValue> param2 = ScriptUtil::getObjectPointer<AnimationValue>(3, "AnimationValue", false, &param2Valid);
  488. if (!param2Valid)
  489. {
  490. lua_pushstring(state, "Failed to convert parameter 2 to type 'AnimationValue'.");
  491. lua_error(state);
  492. }
  493. AnimationTarget* instance = getInstance(state);
  494. instance->getAnimationPropertyValue(param1, param2);
  495. return 0;
  496. }
  497. lua_pushstring(state, "lua_AnimationTarget_getAnimationPropertyValue - Failed to match the given parameters to a valid function signature.");
  498. lua_error(state);
  499. break;
  500. }
  501. default:
  502. {
  503. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  504. lua_error(state);
  505. break;
  506. }
  507. }
  508. return 0;
  509. }
  510. int lua_AnimationTarget_setAnimationPropertyValue(lua_State* state)
  511. {
  512. // Get the number of parameters.
  513. int paramCount = lua_gettop(state);
  514. // Attempt to match the parameters to a valid binding.
  515. switch (paramCount)
  516. {
  517. case 3:
  518. {
  519. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  520. lua_type(state, 2) == LUA_TNUMBER &&
  521. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  522. {
  523. // Get parameter 1 off the stack.
  524. int param1 = (int)luaL_checkint(state, 2);
  525. // Get parameter 2 off the stack.
  526. bool param2Valid;
  527. ScriptUtil::LuaArray<AnimationValue> param2 = ScriptUtil::getObjectPointer<AnimationValue>(3, "AnimationValue", false, &param2Valid);
  528. if (!param2Valid)
  529. {
  530. lua_pushstring(state, "Failed to convert parameter 2 to type 'AnimationValue'.");
  531. lua_error(state);
  532. }
  533. AnimationTarget* instance = getInstance(state);
  534. instance->setAnimationPropertyValue(param1, param2);
  535. return 0;
  536. }
  537. lua_pushstring(state, "lua_AnimationTarget_setAnimationPropertyValue - Failed to match the given parameters to a valid function signature.");
  538. lua_error(state);
  539. break;
  540. }
  541. case 4:
  542. {
  543. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  544. lua_type(state, 2) == LUA_TNUMBER &&
  545. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL) &&
  546. lua_type(state, 4) == LUA_TNUMBER)
  547. {
  548. // Get parameter 1 off the stack.
  549. int param1 = (int)luaL_checkint(state, 2);
  550. // Get parameter 2 off the stack.
  551. bool param2Valid;
  552. ScriptUtil::LuaArray<AnimationValue> param2 = ScriptUtil::getObjectPointer<AnimationValue>(3, "AnimationValue", false, &param2Valid);
  553. if (!param2Valid)
  554. {
  555. lua_pushstring(state, "Failed to convert parameter 2 to type 'AnimationValue'.");
  556. lua_error(state);
  557. }
  558. // Get parameter 3 off the stack.
  559. float param3 = (float)luaL_checknumber(state, 4);
  560. AnimationTarget* instance = getInstance(state);
  561. instance->setAnimationPropertyValue(param1, param2, param3);
  562. return 0;
  563. }
  564. lua_pushstring(state, "lua_AnimationTarget_setAnimationPropertyValue - Failed to match the given parameters to a valid function signature.");
  565. lua_error(state);
  566. break;
  567. }
  568. default:
  569. {
  570. lua_pushstring(state, "Invalid number of parameters (expected 3 or 4).");
  571. lua_error(state);
  572. break;
  573. }
  574. }
  575. return 0;
  576. }
  577. }