lua_AIMessage.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_AIMessage.h"
  4. #include "AIMessage.h"
  5. #include "Base.h"
  6. namespace gameplay
  7. {
  8. void luaRegister_AIMessage()
  9. {
  10. const luaL_Reg lua_members[] =
  11. {
  12. {"getBoolean", lua_AIMessage_getBoolean},
  13. {"getDouble", lua_AIMessage_getDouble},
  14. {"getFloat", lua_AIMessage_getFloat},
  15. {"getId", lua_AIMessage_getId},
  16. {"getInt", lua_AIMessage_getInt},
  17. {"getLong", lua_AIMessage_getLong},
  18. {"getParameterCount", lua_AIMessage_getParameterCount},
  19. {"getParameterType", lua_AIMessage_getParameterType},
  20. {"getReceiver", lua_AIMessage_getReceiver},
  21. {"getSender", lua_AIMessage_getSender},
  22. {"getString", lua_AIMessage_getString},
  23. {"setBoolean", lua_AIMessage_setBoolean},
  24. {"setDouble", lua_AIMessage_setDouble},
  25. {"setFloat", lua_AIMessage_setFloat},
  26. {"setInt", lua_AIMessage_setInt},
  27. {"setLong", lua_AIMessage_setLong},
  28. {"setString", lua_AIMessage_setString},
  29. {NULL, NULL}
  30. };
  31. const luaL_Reg lua_statics[] =
  32. {
  33. {"create", lua_AIMessage_static_create},
  34. {"destroy", lua_AIMessage_static_destroy},
  35. {NULL, NULL}
  36. };
  37. std::vector<std::string> scopePath;
  38. gameplay::ScriptUtil::registerClass("AIMessage", lua_members, NULL, NULL, lua_statics, scopePath);
  39. }
  40. static AIMessage* getInstance(lua_State* state)
  41. {
  42. void* userdata = luaL_checkudata(state, 1, "AIMessage");
  43. luaL_argcheck(state, userdata != NULL, 1, "'AIMessage' expected.");
  44. return (AIMessage*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  45. }
  46. int lua_AIMessage_getBoolean(lua_State* state)
  47. {
  48. // Get the number of parameters.
  49. int paramCount = lua_gettop(state);
  50. // Attempt to match the parameters to a valid binding.
  51. switch (paramCount)
  52. {
  53. case 2:
  54. {
  55. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  56. lua_type(state, 2) == LUA_TNUMBER)
  57. {
  58. // Get parameter 1 off the stack.
  59. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  60. AIMessage* instance = getInstance(state);
  61. bool result = instance->getBoolean(param1);
  62. // Push the return value onto the stack.
  63. lua_pushboolean(state, result);
  64. return 1;
  65. }
  66. lua_pushstring(state, "lua_AIMessage_getBoolean - Failed to match the given parameters to a valid function signature.");
  67. lua_error(state);
  68. break;
  69. }
  70. default:
  71. {
  72. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  73. lua_error(state);
  74. break;
  75. }
  76. }
  77. return 0;
  78. }
  79. int lua_AIMessage_getDouble(lua_State* state)
  80. {
  81. // Get the number of parameters.
  82. int paramCount = lua_gettop(state);
  83. // Attempt to match the parameters to a valid binding.
  84. switch (paramCount)
  85. {
  86. case 2:
  87. {
  88. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  89. lua_type(state, 2) == LUA_TNUMBER)
  90. {
  91. // Get parameter 1 off the stack.
  92. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  93. AIMessage* instance = getInstance(state);
  94. double result = instance->getDouble(param1);
  95. // Push the return value onto the stack.
  96. lua_pushnumber(state, result);
  97. return 1;
  98. }
  99. lua_pushstring(state, "lua_AIMessage_getDouble - Failed to match the given parameters to a valid function signature.");
  100. lua_error(state);
  101. break;
  102. }
  103. default:
  104. {
  105. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  106. lua_error(state);
  107. break;
  108. }
  109. }
  110. return 0;
  111. }
  112. int lua_AIMessage_getFloat(lua_State* state)
  113. {
  114. // Get the number of parameters.
  115. int paramCount = lua_gettop(state);
  116. // Attempt to match the parameters to a valid binding.
  117. switch (paramCount)
  118. {
  119. case 2:
  120. {
  121. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  122. lua_type(state, 2) == LUA_TNUMBER)
  123. {
  124. // Get parameter 1 off the stack.
  125. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  126. AIMessage* instance = getInstance(state);
  127. float result = instance->getFloat(param1);
  128. // Push the return value onto the stack.
  129. lua_pushnumber(state, result);
  130. return 1;
  131. }
  132. lua_pushstring(state, "lua_AIMessage_getFloat - Failed to match the given parameters to a valid function signature.");
  133. lua_error(state);
  134. break;
  135. }
  136. default:
  137. {
  138. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  139. lua_error(state);
  140. break;
  141. }
  142. }
  143. return 0;
  144. }
  145. int lua_AIMessage_getId(lua_State* state)
  146. {
  147. // Get the number of parameters.
  148. int paramCount = lua_gettop(state);
  149. // Attempt to match the parameters to a valid binding.
  150. switch (paramCount)
  151. {
  152. case 1:
  153. {
  154. if ((lua_type(state, 1) == LUA_TUSERDATA))
  155. {
  156. AIMessage* instance = getInstance(state);
  157. unsigned int result = instance->getId();
  158. // Push the return value onto the stack.
  159. lua_pushunsigned(state, result);
  160. return 1;
  161. }
  162. lua_pushstring(state, "lua_AIMessage_getId - Failed to match the given parameters to a valid function signature.");
  163. lua_error(state);
  164. break;
  165. }
  166. default:
  167. {
  168. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  169. lua_error(state);
  170. break;
  171. }
  172. }
  173. return 0;
  174. }
  175. int lua_AIMessage_getInt(lua_State* state)
  176. {
  177. // Get the number of parameters.
  178. int paramCount = lua_gettop(state);
  179. // Attempt to match the parameters to a valid binding.
  180. switch (paramCount)
  181. {
  182. case 2:
  183. {
  184. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  185. lua_type(state, 2) == LUA_TNUMBER)
  186. {
  187. // Get parameter 1 off the stack.
  188. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  189. AIMessage* instance = getInstance(state);
  190. int result = instance->getInt(param1);
  191. // Push the return value onto the stack.
  192. lua_pushinteger(state, result);
  193. return 1;
  194. }
  195. lua_pushstring(state, "lua_AIMessage_getInt - Failed to match the given parameters to a valid function signature.");
  196. lua_error(state);
  197. break;
  198. }
  199. default:
  200. {
  201. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  202. lua_error(state);
  203. break;
  204. }
  205. }
  206. return 0;
  207. }
  208. int lua_AIMessage_getLong(lua_State* state)
  209. {
  210. // Get the number of parameters.
  211. int paramCount = lua_gettop(state);
  212. // Attempt to match the parameters to a valid binding.
  213. switch (paramCount)
  214. {
  215. case 2:
  216. {
  217. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  218. lua_type(state, 2) == LUA_TNUMBER)
  219. {
  220. // Get parameter 1 off the stack.
  221. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  222. AIMessage* instance = getInstance(state);
  223. long result = instance->getLong(param1);
  224. // Push the return value onto the stack.
  225. lua_pushinteger(state, result);
  226. return 1;
  227. }
  228. lua_pushstring(state, "lua_AIMessage_getLong - Failed to match the given parameters to a valid function signature.");
  229. lua_error(state);
  230. break;
  231. }
  232. default:
  233. {
  234. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  235. lua_error(state);
  236. break;
  237. }
  238. }
  239. return 0;
  240. }
  241. int lua_AIMessage_getParameterCount(lua_State* state)
  242. {
  243. // Get the number of parameters.
  244. int paramCount = lua_gettop(state);
  245. // Attempt to match the parameters to a valid binding.
  246. switch (paramCount)
  247. {
  248. case 1:
  249. {
  250. if ((lua_type(state, 1) == LUA_TUSERDATA))
  251. {
  252. AIMessage* instance = getInstance(state);
  253. unsigned int result = instance->getParameterCount();
  254. // Push the return value onto the stack.
  255. lua_pushunsigned(state, result);
  256. return 1;
  257. }
  258. lua_pushstring(state, "lua_AIMessage_getParameterCount - Failed to match the given parameters to a valid function signature.");
  259. lua_error(state);
  260. break;
  261. }
  262. default:
  263. {
  264. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  265. lua_error(state);
  266. break;
  267. }
  268. }
  269. return 0;
  270. }
  271. int lua_AIMessage_getParameterType(lua_State* state)
  272. {
  273. // Get the number of parameters.
  274. int paramCount = lua_gettop(state);
  275. // Attempt to match the parameters to a valid binding.
  276. switch (paramCount)
  277. {
  278. case 2:
  279. {
  280. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  281. lua_type(state, 2) == LUA_TNUMBER)
  282. {
  283. // Get parameter 1 off the stack.
  284. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  285. AIMessage* instance = getInstance(state);
  286. AIMessage::ParameterType result = instance->getParameterType(param1);
  287. // Push the return value onto the stack.
  288. lua_pushnumber(state, (int)result);
  289. return 1;
  290. }
  291. lua_pushstring(state, "lua_AIMessage_getParameterType - Failed to match the given parameters to a valid function signature.");
  292. lua_error(state);
  293. break;
  294. }
  295. default:
  296. {
  297. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  298. lua_error(state);
  299. break;
  300. }
  301. }
  302. return 0;
  303. }
  304. int lua_AIMessage_getReceiver(lua_State* state)
  305. {
  306. // Get the number of parameters.
  307. int paramCount = lua_gettop(state);
  308. // Attempt to match the parameters to a valid binding.
  309. switch (paramCount)
  310. {
  311. case 1:
  312. {
  313. if ((lua_type(state, 1) == LUA_TUSERDATA))
  314. {
  315. AIMessage* instance = getInstance(state);
  316. const char* result = instance->getReceiver();
  317. // Push the return value onto the stack.
  318. lua_pushstring(state, result);
  319. return 1;
  320. }
  321. lua_pushstring(state, "lua_AIMessage_getReceiver - Failed to match the given parameters to a valid function signature.");
  322. lua_error(state);
  323. break;
  324. }
  325. default:
  326. {
  327. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  328. lua_error(state);
  329. break;
  330. }
  331. }
  332. return 0;
  333. }
  334. int lua_AIMessage_getSender(lua_State* state)
  335. {
  336. // Get the number of parameters.
  337. int paramCount = lua_gettop(state);
  338. // Attempt to match the parameters to a valid binding.
  339. switch (paramCount)
  340. {
  341. case 1:
  342. {
  343. if ((lua_type(state, 1) == LUA_TUSERDATA))
  344. {
  345. AIMessage* instance = getInstance(state);
  346. const char* result = instance->getSender();
  347. // Push the return value onto the stack.
  348. lua_pushstring(state, result);
  349. return 1;
  350. }
  351. lua_pushstring(state, "lua_AIMessage_getSender - Failed to match the given parameters to a valid function signature.");
  352. lua_error(state);
  353. break;
  354. }
  355. default:
  356. {
  357. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  358. lua_error(state);
  359. break;
  360. }
  361. }
  362. return 0;
  363. }
  364. int lua_AIMessage_getString(lua_State* state)
  365. {
  366. // Get the number of parameters.
  367. int paramCount = lua_gettop(state);
  368. // Attempt to match the parameters to a valid binding.
  369. switch (paramCount)
  370. {
  371. case 2:
  372. {
  373. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  374. lua_type(state, 2) == LUA_TNUMBER)
  375. {
  376. // Get parameter 1 off the stack.
  377. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  378. AIMessage* instance = getInstance(state);
  379. const char* result = instance->getString(param1);
  380. // Push the return value onto the stack.
  381. lua_pushstring(state, result);
  382. return 1;
  383. }
  384. lua_pushstring(state, "lua_AIMessage_getString - Failed to match the given parameters to a valid function signature.");
  385. lua_error(state);
  386. break;
  387. }
  388. default:
  389. {
  390. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  391. lua_error(state);
  392. break;
  393. }
  394. }
  395. return 0;
  396. }
  397. int lua_AIMessage_setBoolean(lua_State* state)
  398. {
  399. // Get the number of parameters.
  400. int paramCount = lua_gettop(state);
  401. // Attempt to match the parameters to a valid binding.
  402. switch (paramCount)
  403. {
  404. case 3:
  405. {
  406. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  407. lua_type(state, 2) == LUA_TNUMBER &&
  408. lua_type(state, 3) == LUA_TBOOLEAN)
  409. {
  410. // Get parameter 1 off the stack.
  411. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  412. // Get parameter 2 off the stack.
  413. bool param2 = gameplay::ScriptUtil::luaCheckBool(state, 3);
  414. AIMessage* instance = getInstance(state);
  415. instance->setBoolean(param1, param2);
  416. return 0;
  417. }
  418. lua_pushstring(state, "lua_AIMessage_setBoolean - Failed to match the given parameters to a valid function signature.");
  419. lua_error(state);
  420. break;
  421. }
  422. default:
  423. {
  424. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  425. lua_error(state);
  426. break;
  427. }
  428. }
  429. return 0;
  430. }
  431. int lua_AIMessage_setDouble(lua_State* state)
  432. {
  433. // Get the number of parameters.
  434. int paramCount = lua_gettop(state);
  435. // Attempt to match the parameters to a valid binding.
  436. switch (paramCount)
  437. {
  438. case 3:
  439. {
  440. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  441. lua_type(state, 2) == LUA_TNUMBER &&
  442. lua_type(state, 3) == LUA_TNUMBER)
  443. {
  444. // Get parameter 1 off the stack.
  445. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  446. // Get parameter 2 off the stack.
  447. double param2 = (double)luaL_checknumber(state, 3);
  448. AIMessage* instance = getInstance(state);
  449. instance->setDouble(param1, param2);
  450. return 0;
  451. }
  452. lua_pushstring(state, "lua_AIMessage_setDouble - Failed to match the given parameters to a valid function signature.");
  453. lua_error(state);
  454. break;
  455. }
  456. default:
  457. {
  458. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  459. lua_error(state);
  460. break;
  461. }
  462. }
  463. return 0;
  464. }
  465. int lua_AIMessage_setFloat(lua_State* state)
  466. {
  467. // Get the number of parameters.
  468. int paramCount = lua_gettop(state);
  469. // Attempt to match the parameters to a valid binding.
  470. switch (paramCount)
  471. {
  472. case 3:
  473. {
  474. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  475. lua_type(state, 2) == LUA_TNUMBER &&
  476. lua_type(state, 3) == LUA_TNUMBER)
  477. {
  478. // Get parameter 1 off the stack.
  479. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  480. // Get parameter 2 off the stack.
  481. float param2 = (float)luaL_checknumber(state, 3);
  482. AIMessage* instance = getInstance(state);
  483. instance->setFloat(param1, param2);
  484. return 0;
  485. }
  486. lua_pushstring(state, "lua_AIMessage_setFloat - Failed to match the given parameters to a valid function signature.");
  487. lua_error(state);
  488. break;
  489. }
  490. default:
  491. {
  492. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  493. lua_error(state);
  494. break;
  495. }
  496. }
  497. return 0;
  498. }
  499. int lua_AIMessage_setInt(lua_State* state)
  500. {
  501. // Get the number of parameters.
  502. int paramCount = lua_gettop(state);
  503. // Attempt to match the parameters to a valid binding.
  504. switch (paramCount)
  505. {
  506. case 3:
  507. {
  508. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  509. lua_type(state, 2) == LUA_TNUMBER &&
  510. lua_type(state, 3) == LUA_TNUMBER)
  511. {
  512. // Get parameter 1 off the stack.
  513. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  514. // Get parameter 2 off the stack.
  515. int param2 = (int)luaL_checkint(state, 3);
  516. AIMessage* instance = getInstance(state);
  517. instance->setInt(param1, param2);
  518. return 0;
  519. }
  520. lua_pushstring(state, "lua_AIMessage_setInt - Failed to match the given parameters to a valid function signature.");
  521. lua_error(state);
  522. break;
  523. }
  524. default:
  525. {
  526. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  527. lua_error(state);
  528. break;
  529. }
  530. }
  531. return 0;
  532. }
  533. int lua_AIMessage_setLong(lua_State* state)
  534. {
  535. // Get the number of parameters.
  536. int paramCount = lua_gettop(state);
  537. // Attempt to match the parameters to a valid binding.
  538. switch (paramCount)
  539. {
  540. case 3:
  541. {
  542. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  543. lua_type(state, 2) == LUA_TNUMBER &&
  544. lua_type(state, 3) == LUA_TNUMBER)
  545. {
  546. // Get parameter 1 off the stack.
  547. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  548. // Get parameter 2 off the stack.
  549. long param2 = (long)luaL_checklong(state, 3);
  550. AIMessage* instance = getInstance(state);
  551. instance->setLong(param1, param2);
  552. return 0;
  553. }
  554. lua_pushstring(state, "lua_AIMessage_setLong - Failed to match the given parameters to a valid function signature.");
  555. lua_error(state);
  556. break;
  557. }
  558. default:
  559. {
  560. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  561. lua_error(state);
  562. break;
  563. }
  564. }
  565. return 0;
  566. }
  567. int lua_AIMessage_setString(lua_State* state)
  568. {
  569. // Get the number of parameters.
  570. int paramCount = lua_gettop(state);
  571. // Attempt to match the parameters to a valid binding.
  572. switch (paramCount)
  573. {
  574. case 3:
  575. {
  576. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  577. lua_type(state, 2) == LUA_TNUMBER &&
  578. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
  579. {
  580. // Get parameter 1 off the stack.
  581. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  582. // Get parameter 2 off the stack.
  583. const char* param2 = gameplay::ScriptUtil::getString(3, false);
  584. AIMessage* instance = getInstance(state);
  585. instance->setString(param1, param2);
  586. return 0;
  587. }
  588. lua_pushstring(state, "lua_AIMessage_setString - Failed to match the given parameters to a valid function signature.");
  589. lua_error(state);
  590. break;
  591. }
  592. default:
  593. {
  594. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  595. lua_error(state);
  596. break;
  597. }
  598. }
  599. return 0;
  600. }
  601. int lua_AIMessage_static_create(lua_State* state)
  602. {
  603. // Get the number of parameters.
  604. int paramCount = lua_gettop(state);
  605. // Attempt to match the parameters to a valid binding.
  606. switch (paramCount)
  607. {
  608. case 4:
  609. {
  610. if (lua_type(state, 1) == LUA_TNUMBER &&
  611. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  612. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
  613. lua_type(state, 4) == LUA_TNUMBER)
  614. {
  615. // Get parameter 1 off the stack.
  616. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 1);
  617. // Get parameter 2 off the stack.
  618. const char* param2 = gameplay::ScriptUtil::getString(2, false);
  619. // Get parameter 3 off the stack.
  620. const char* param3 = gameplay::ScriptUtil::getString(3, false);
  621. // Get parameter 4 off the stack.
  622. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 4);
  623. void* returnPtr = (void*)AIMessage::create(param1, param2, param3, param4);
  624. if (returnPtr)
  625. {
  626. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  627. object->instance = returnPtr;
  628. object->owns = false;
  629. luaL_getmetatable(state, "AIMessage");
  630. lua_setmetatable(state, -2);
  631. }
  632. else
  633. {
  634. lua_pushnil(state);
  635. }
  636. return 1;
  637. }
  638. lua_pushstring(state, "lua_AIMessage_static_create - Failed to match the given parameters to a valid function signature.");
  639. lua_error(state);
  640. break;
  641. }
  642. default:
  643. {
  644. lua_pushstring(state, "Invalid number of parameters (expected 4).");
  645. lua_error(state);
  646. break;
  647. }
  648. }
  649. return 0;
  650. }
  651. int lua_AIMessage_static_destroy(lua_State* state)
  652. {
  653. // Get the number of parameters.
  654. int paramCount = lua_gettop(state);
  655. // Attempt to match the parameters to a valid binding.
  656. switch (paramCount)
  657. {
  658. case 1:
  659. {
  660. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
  661. {
  662. // Get parameter 1 off the stack.
  663. bool param1Valid;
  664. gameplay::ScriptUtil::LuaArray<AIMessage> param1 = gameplay::ScriptUtil::getObjectPointer<AIMessage>(1, "AIMessage", false, &param1Valid);
  665. if (!param1Valid)
  666. {
  667. lua_pushstring(state, "Failed to convert parameter 1 to type 'AIMessage'.");
  668. lua_error(state);
  669. }
  670. AIMessage::destroy(param1);
  671. return 0;
  672. }
  673. lua_pushstring(state, "lua_AIMessage_static_destroy - Failed to match the given parameters to a valid function signature.");
  674. lua_error(state);
  675. break;
  676. }
  677. default:
  678. {
  679. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  680. lua_error(state);
  681. break;
  682. }
  683. }
  684. return 0;
  685. }
  686. }