Techial

C++ LUA Debugger

Dec 15th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. // LUA Debugger made from scratch by: Techial
  2. // Cross-Platform corrections by: Sant
  3. // Currently tested: Windows 7 and OpenSuse
  4.  
  5.  
  6. #ifdef WIN_32
  7. #pragma comment(lib,"lua5.1.lib")
  8.  
  9. #include <conio.h>
  10. #else
  11. #include <curses.h>
  12. #endif
  13.  
  14. #include <stdio.h>
  15. #include <iostream>
  16. #include <string>
  17. #include <sstream>
  18. using namespace std;
  19.  
  20. extern "C"{
  21. #include "lua.h"
  22. #include "lualib.h"
  23. #include "lauxlib.h"
  24. }
  25.  
  26. const char* convString(string ans)
  27. {
  28.     char * lv;
  29.     char * stringChar = new char[ans.size() + 1];
  30.     copy(ans.begin(), ans.end(), stringChar);
  31.     stringChar[ans.size()] = '\0';
  32.     lv = stringChar;
  33.     return lv;
  34. }
  35.  
  36. int main()
  37. {
  38.     cout << "Type in the file of the LUA file to debug, example: test.lua\nName: ";
  39.     string ans;
  40.     getline(cin, ans);
  41.     #ifndef _WIN32
  42.         clear();
  43.         //system("clear");
  44.     #else
  45.         system("cls");
  46.     #endif
  47.     lua_State *Debug = lua_open();
  48.     luaL_openlibs(Debug);
  49.     luaL_dofile(Debug,convString(ans));
  50.     lua_close(Debug);
  51. #ifndef WIN_32
  52.     wgetch(0);
  53. #else
  54.     getch();
  55. #endif
  56.     return 0;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment