Example: (will follow a creature named Syntax)
NOTEs:
luascript.cpp
After the line: lua_register(m_luaState, "doPlayerSetPartner", LuaInterface::luaDoPlayerSetPartner); ADD:
After the function: int32_t LuaInterface::luaDoPlayerSetPartner(lua_State* L) ADD:
luascript.h
After the line: static int32_t luaDoPlayerSetPartner(lua_State* L); ADD:
Enjoy.
Code:
doPlayerFollowCreature(cid,getCreatureName("Syntax")
Code:
Green square will not appear as if followed through client.
Only supports players following creatures, not vice-versa.
luascript.cpp
After the line: lua_register(m_luaState, "doPlayerSetPartner", LuaInterface::luaDoPlayerSetPartner); ADD:
Code:
//doPlayerFollowCreature(cid)
lua_register(m_luaState, "doPlayerFollowCreature", LuaInterface::luaDoPlayerFollowCreature);
Code:
int32_t LuaInterface::luaDoPlayerFollowCreature(lua_State* L)
{
//doPlayerFollowCreature(cid, target)
ScriptEnviroment* env = getEnv();
Creature* creature = env->getCreatureByUID(popNumber(L));
if(!creature)
{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
Player* player = env->getPlayerByUID(popNumber(L));
if(!player)
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
g_game.playerFollowCreature(player->getID(), creature->getID());
lua_pushboolean(L, true);
return 1;
}
After the line: static int32_t luaDoPlayerSetPartner(lua_State* L); ADD:
Code:
static int32_t luaDoPlayerFollowCreature(lua_State* L);
Enjoy.