Is there any way to make creep use a predefined path?



  • For example I have

    flag1
    flag2
    
    var path1 = flag1.pos.findPathTo(flag2)
    

    then if I call creep.moveTo(path1), i get ERR_INVALID_TARGET

    I wish the creep to move to the nearest point of found path or use the path for navigation



  • You are probably looking for Creep.move()



  • Creep.move(mypath[stepnumber].direction) should work, but creep has to the stepnumber in memory



  • Path calculated by vanilla moveTo is stored in creep memory -
    Urist.memory._move = {dest:{x:666, y:666}, path:[{dir:BOTTOM, x:665, y:665}, ...], last:{...}}
    If you want to execute this manually, I'd find the path entry with Urist's pos and execute move on the next path array element dir;
    If you fail to find the Urist' pos in path, try to find a path node that is 1 space away from Urist - recalculate it's dir though;
    Failing to find that, recalculate whole path.


  • Dev Team

    There is new method Creep.moveByPath for this purpose now.