Doggynub
LUA / C++
- Joined
- Sep 28, 2008
- Messages
- 2,541
- Reaction score
- 186
Well thought of this when i saw this thread http://otland.net/f35/coordinates-159038/
This function copy the text to the clipboard (ie: as if you made ctrl+c to the text)
luascript.h
find
[cpp]
static int32_t luaStdSHA512(lua_State* L);[/cpp]
and place this under
[cpp]
static int32_t luaClipboardCopy(lua_State* L);[/cpp]
luascript.cpp
find
[cpp]
//setCreatureMaxMana(cid, mana)[/cpp]
paste this above
[cpp]
//clipboardCopy(text)
lua_register(m_luaState, "clipboardCopy", LuaInterface::luaClipboardCopy);
[/cpp]
then find
[cpp]
int32_t LuaInterface::luaSetCreatureMaxMana(lua_State* L)
[/cpp]
and paste this above
[cpp]
int32_t LuaInterface::luaClipboardCopy(lua_State* L)
{
//clipboardCopy(text)
std::string text = popString(L);
if(text != "")
{
const char* output = text.c_str();
const size_t len = strlen(output) + 1;
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len);
memcpy(GlobalLock(hMem), output, len);
GlobalUnlock(hMem);
OpenClipboard(0);
EmptyClipboard();
if(SetClipboardData(CF_TEXT, hMem) != NULL)
lua_pushboolean(L,true);
else
lua_pushboolean(L,false);
CloseClipboard();
}
return 1;
}
[/cpp]
You can use like that
This function copy the text to the clipboard (ie: as if you made ctrl+c to the text)
luascript.h
find
[cpp]
static int32_t luaStdSHA512(lua_State* L);[/cpp]
and place this under
[cpp]
static int32_t luaClipboardCopy(lua_State* L);[/cpp]
luascript.cpp
find
[cpp]
//setCreatureMaxMana(cid, mana)[/cpp]
paste this above
[cpp]
//clipboardCopy(text)
lua_register(m_luaState, "clipboardCopy", LuaInterface::luaClipboardCopy);
[/cpp]
then find
[cpp]
int32_t LuaInterface::luaSetCreatureMaxMana(lua_State* L)
[/cpp]
and paste this above
[cpp]
int32_t LuaInterface::luaClipboardCopy(lua_State* L)
{
//clipboardCopy(text)
std::string text = popString(L);
if(text != "")
{
const char* output = text.c_str();
const size_t len = strlen(output) + 1;
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len);
memcpy(GlobalLock(hMem), output, len);
GlobalUnlock(hMem);
OpenClipboard(0);
EmptyClipboard();
if(SetClipboardData(CF_TEXT, hMem) != NULL)
lua_pushboolean(L,true);
else
lua_pushboolean(L,false);
CloseClipboard();
}
return 1;
}
[/cpp]
You can use like that
Lua:
function onLook(cid, thing, position, lookDistance)
if getPlayerGroupId(cid) >= 4 then
local str = string.gsub("{x = |x|, y = |y|, z = |z|, stackpos = |stackpos|}","|(.-)|",function(a) return position[a] end)
if not clipboardCopy(str) then
print("error in copying to clipboard, no data copied.")
end
end
return true
end