2
0

lua_AnimationTarget.cpp 25 KB

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