Creep.moveTo returns -9 which is not documented



  • Creep.moveTo() documentation does not show -9:

    ERR_NOT_IN_RANGE

    Yet I'm getting this when I attempt to move somewhere which has a creep traffic jam. I think it means that the Pathfinder wasn't able to find a way to get there. However, this should be documented clearly in the API documentation please.

    Is there a way to tell the moveTo() to go as get as close as possible instead of just giving me an error and not moving?

    Thanks!


  • Dev Team

    Creep.moveTo never returns ERR_NOT_IN_RANGE. Most likely you are either overriding this method somehow or just modifying the resulting value.



  • Thanks Artem. You're right. I was logging the wrong value to the console (what a moron I am).

    It's actually returning -2:

    ERR_NO_PATH

    My question is then, can you have it move toward it if it gets no path? What can I do to get the creep moving closer?

    const r2 = creep.moveTo(sources[which_source], {maxRooms: 1, range: 1});
    if (r2 != OK) {
    console.log(creep.name, creep.room.name, 'harvest moving result:', r2);
    }

  • Dev Team

    Moving towards the goal if there is no full path is basically the default behavior. ERR_NO_PATH is returned when there is really no path steps available, e.g. when a creep is surrounded by obstacles. Could you provide an isolated test case using bare PathFinder (without Room methods involved) that doesn’t match this behavior?