CLua.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "stdafx.h"
  2. #include "CLua.h"
  3. #include "CLuaHandler.h"
  4. #include "lualib.h"
  5. #include "lauxlib.h"
  6. CObjectScript::CObjectScript()
  7. {
  8. //std::cout << "Tworze obiekt objectscript "<<this<<std::endl;
  9. }
  10. CObjectScript::~CObjectScript()
  11. {
  12. //std::cout << "Usuwam obiekt objectscript "<<this<<std::endl;
  13. }
  14. CScript::CScript()
  15. {
  16. //std::cout << "Tworze obiekt CScript "<<this<<std::endl;
  17. }
  18. CScript::~CScript()
  19. {
  20. //std::cout << "Usuwam obiekt CScript "<<this<<std::endl;
  21. }
  22. #define LST (is)
  23. CLua::CLua(std::string initpath)
  24. {
  25. opened=false;
  26. LST = lua_open();
  27. opened = true;
  28. LUA_OPEN_LIB(LST, luaopen_base);
  29. LUA_OPEN_LIB(LST, luaopen_io);
  30. if ((luaL_loadfile (LST, "test.lua")) == 0)
  31. {
  32. //lua_pcall (LST, 0, LUA_MULTRET, 0);
  33. }
  34. else
  35. {
  36. std::string temp = "Cannot open script";
  37. temp += initpath;
  38. throw std::exception(temp.c_str());
  39. }
  40. }
  41. CLua::CLua()
  42. {
  43. //std::cout << "Tworze obiekt clua "<<this<<std::endl;
  44. opened=false;
  45. }
  46. void CLua::registerCLuaCallback()
  47. {
  48. }
  49. CLua::~CLua()
  50. {
  51. //std::cout << "Usuwam obiekt clua "<<this<<std::endl;
  52. if (opened)
  53. {
  54. std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<std::endl;
  55. lua_close(LST);
  56. }
  57. }
  58. #undef LST
  59. CLuaObjectScript::CLuaObjectScript()
  60. {
  61. //std::cout << "Tworze obiekt CLuaObjectScript "<<this<<std::endl;
  62. }
  63. CLuaObjectScript::~CLuaObjectScript()
  64. {
  65. //std::cout << "Usuwam obiekt CLuaObjectScript "<<this<<std::endl;
  66. }