Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int CopyString(lua_State *Ls) {
- const char* str = lua_tostring(Ls, -1);
- int len = strlen(str);
- HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len + 1);
- void *mem_ptr = GlobalLock(hMem);
- memcpy(mem_ptr, str, len + 1);
- GlobalUnlock(hMem);
- OpenClipboard(NULL);
- EmptyClipboard();
- SetClipboardData(CF_TEXT, hMem);
- CloseClipboard();
- return 0;
- }
- void GetFile(const char* dllName, const char* fileName, char* buffer, int bfSize) {
- GetModuleFileName(GetModuleHandle(dllName), buffer, bfSize);
- if (strlen(fileName) + strlen(buffer) < MAX_PATH) {
- char* pathEnd = strrchr(buffer, '\\');
- strcpy(pathEnd + 1, fileName);
- }
- else {
- *buffer = 0;
- }
- }
- int luawritefile(lua_State* r_lua_State) {
- const char * nameoffile = lua_tostring(r_lua_State, -1);
- const char * contentsoffile = lua_tostring(r_lua_State, -2);
- char path[MAX_PATH];
- GetFile("Chaosity.dll", "", path, MAX_PATH);
- std::string Lean;
- Lean += path;
- Lean += "Scripts\\";
- Lean += contentsoffile;
- std::ofstream o(Lean.c_str());
- return 1;
- }
- int custom_readfile(lua_State* r_lua_State) {
- const char * nameoffile = lua_tostring(r_lua_State, -1);
- char path[MAX_PATH];
- GetFile("Chaosity.dll", "", path, MAX_PATH);
- std::string file;
- file += path;
- file += "Workspace\\";
- file += nameoffile;
- printf(file.c_str());
- string line;
- ifstream myfile(file);
- if (myfile.is_open())
- {
- while (getline(myfile, line))
- {
- lua_pushstring(r_lua_State, line.c_str());
- }
- myfile.close();
- }
- return 1;
- }
- static int custom_runfile(lua_State *lua_State) {
- const char * name = r_lua_tolstring(m_rL, -1, 0);
- char path[MAX_PATH];
- GetFile("Chaosity.dll", "", path, MAX_PATH);
- std::string file;
- file += path;
- file += "Workspace//";
- file += name;
- std::ifstream swfile(file);
- std::string line;
- if (swfile.is_open())
- {
- while (getline(swfile, line))
- {
- Wrapped(line);
- }
- swfile.close();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment