16 lines
625 B
JavaScript
16 lines
625 B
JavaScript
|
|
/* ########################################
|
|
# Mine energy and drop it in container #
|
|
########################################*/
|
|
|
|
module.exports = {
|
|
do: function(creep){
|
|
var container = Game.getObjectById(creep.memory.container_id);
|
|
if(container != null && creep.pos.isEqualTo(container.pos)){
|
|
if(creep.memory.source_id == undefined) creep.memory.source_id = creep.pos.findClosestByPath(FIND_SOURCES).id;
|
|
creep.harvest(Game.getObjectById(creep.memory.source_id));
|
|
} else {
|
|
creep.moveTo(Game.getObjectById(creep.memory.container_id));
|
|
}
|
|
}
|
|
}; |