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;
}