Error unable to find path
-
I have created a small script. After some trying I cannot find where my mistake is... I keep getting error no path found (creep.moveto() returns -2). Here is my code:
var roleHarvester = { /** @param {Creep} creep **/ run: function(creep) { if(creep.carry.energy < creep.carryCapacity) { var source = creep.room.find(FIND_SOURCES)[1]; if(creep.harvest(source) == ERR_NOT_IN_RANGE) { console.log('x: ' + source.pos.x); console.log('y: ' + source.pos.y); if (creep.moveTo(source) == -2) { console.log('Cannot find path'); } } } else { if(creep.transfer(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { creep.moveTo(Game.spawns['Spawn1']); } } } }; module.exports = roleHarvester;
It shows in the log:
x: 11 y: 30 Cannot find path
The x and y value are the correct values of the source.
Why can't it find it's path?
-
same issue that have been reported here i guess: https://screeps.com/forum/topic/2257/creep-moveto-almost-always-returning-2
Basically the terrain is "wall" where it should not be. Seen a lot of people reporting this.