DedicatedOT
New Member
REP++ if you can post the code for that function.
int32_t LuaScriptInterface::luaDoCreatureSetLookDir(lua_State* L)
{
//doCreatureSetLookDir(cid, dir)
Direction dir = (Direction)popNumber(L);
ScriptEnviroment* env = getScriptEnv();
if(Creature* creature = env->getCreatureByUID(popNumber(L)))
{
if(dir < NORTH || dir > WEST)
{
std::stringstream ss;
ss << dir;
reportErrorFunc("Invalid direction " + ss.str());
lua_pushboolean(L, LUA_ERROR);
return 1;
}
g_game.internalCreatureTurn(creature, dir);
if(Player* player = creature->getPlayer())
player->resetIdleTime();
lua_pushboolean(L, LUA_NO_ERROR);
}
else
{
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, LUA_ERROR);
}
return 1;
}
NORTH = 0
EAST = 1
SOUTH = 2
WEST = 3
SOUTHWEST = 4
SOUTHEAST = 5
NORTHWEST = 6
NORTHEAST = 7
doCreatureSetLookDir(cid, SOUTH)
Code:int32_t LuaScriptInterface::luaDoCreatureSetLookDir(lua_State* L) { //doCreatureSetLookDir(cid, dir) Direction dir = (Direction)popNumber(L); ScriptEnviroment* env = getScriptEnv(); if(Creature* creature = env->getCreatureByUID(popNumber(L))) { if(dir < NORTH || dir > WEST) { std::stringstream ss; ss << dir; reportErrorFunc("Invalid direction " + ss.str()); lua_pushboolean(L, LUA_ERROR); return 1; } g_game.internalCreatureTurn(creature, dir); if(Player* player = creature->getPlayer()) player->resetIdleTime(); lua_pushboolean(L, LUA_NO_ERROR); } else { reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, LUA_ERROR); } return 1; }
Thanks. This is Luascript.cpp? Do I add anything in Luascript.h?
//doCreatureSetLookDir(cid, dir)
lua_register(m_luaState, "doCreatureSetLookDirection", LuaScriptInterface::luaDoCreatureSetLookDir);
static int32_t luaDoCreatureSetLookDir(lua_State* L);