I had a problem with creep jumping swapping between rooms. It seem like creep.room changes to a new room on second turn being in new room. However we need to move on the first tick not second in the new room. I haven`t figured out exact rule for that but this seems to fixed it for me.
[code]
// START OF HARVESTING
if(creep_action == 'harvesting') {
var targetRoomName = creep.memory.target;// load target room from creep memory
if(creep.room.name != targetRoomName || (creep.room.name == targetRoomName && borderPosition(creep))){
var targetPos = new RoomPosition(25,25, targetRoomName); // create position in the middle of target room.
creep.moveTo(targetPos);
} else {
// when you are in the specified room find resource and go to it.
var target_srouce = Game.rooms[targetRoomName].find(FIND_SOURCES)[creep.memory.sourceIndex];
if(creep.harvest(target_srouce) == ERR_NOT_IN_RANGE) {
creep.moveTo(target_srouce.pos);
}
}
}
// END OF HARVESTING
[/code]
1, there is a condition which check if we are not in the new room OR we are in the new room AND creep is in any of the border positions borderPosition(). if X or Y is either 0 or 49). then he still need to move on to the predefined position in the target room.
2, finally when creep gets out of border space he look for the resource to mine.
I don`t believe this is good solution , but it works for me until I find better one.