rendered paste body
// change this:
int32_t LuaScriptInterface::luaDoMoveCreature(lua_State *L)
{
//doMoveCreature(cid, direction)
uint32_t direction = popNumber(L);
uint32_t cid = popNumber(L);
switch(direction){
case NORTH:
case SOUTH:
case WEST:
case EAST:
case SOUTHWEST:
case NORTHWEST:
case NORTHEAST:
case SOUTHEAST:
break;
default:
reportErrorFunc("No valid direction");
lua_pushnumber(L, LUA_ERROR);
return 1;
}
ScriptEnviroment* env = getScriptEnv();
Creature* creature = env->getCreatureByUID(cid);
if(creature){
ReturnValue ret = g_game.internalMoveCreature(creature, (Direction)direction, true);
lua_pushnumber(L, ret);
}
else{
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushnumber(L, LUA_ERROR);
}
return 1;
}
// to this:
int32_t LuaScriptInterface::luaDoMoveCreature(lua_State *L)
{
//doMoveCreature(cid, direction, force)
uint32_t force = popNumber(L);
uint32_t direction = popNumber(L);
uint32_t cid = popNumber(L);
switch(direction){
case NORTH:
case SOUTH:
case WEST:
case EAST:
case SOUTHWEST:
case NORTHWEST:
case NORTHEAST:
case SOUTHEAST:
break;
default:
reportErrorFunc("No valid direction");
lua_pushnumber(L, LUA_ERROR);
return 1;
}
ScriptEnviroment* env = getScriptEnv();
Creature* creature = env->getCreatureByUID(cid);
if(creature){
ReturnValue ret = g_game.internalMoveCreature(creature, (Direction)direction, (force != 0));
lua_pushnumber(L, ret);
}
else{
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushnumber(L, LUA_ERROR);
}
return 1;
}
/*
new sintax:
doMoveCreature(cid, direction, force)
if force = 0 then the function will not move into walls and etc.
*/