forked from screeps/tutorial-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Road Repair
Warren Earle edited this page Jun 28, 2016
·
1 revision
module.exports = function (creep) {
if(creep.energy == 0) {
var spwn = creep.pos.findClosest(FIND_MY_SPAWNS);
creep.moveTo(spwn);
if((spwn) > [199]) {
spwn.transferEnergy(creep);
}}
else{
var roadRepair = creep.pos.findClosest(FIND_STRUCTURES, {
filter: function(object){
if(object.structureType != STRUCTURE_ROAD ) {
return false;
}
if(object.hits > object.hitsMax / 3) {
return false;
}
return true;
}
});
creep.moveTo(roadRepair);
creep.repair(roadRepair);}
};