screep/builder.js

14 lines
484 B
JavaScript
Raw Normal View History

2020-10-18 22:00:22 +08:00
module.exports = {
run(creep) {
if (creep.carry.energy < creep.carryCapacity){
if(ERR_NOT_IN_RANGE==creep.withdraw(Game.spawns.Spawn1,RESOURCE_ENERGY)){
creep.moveTo(Game.spawns.Spawn1);
}
}else{
let construction_site=creep.room.find(FIND_CONSTRUCTION_SITES);
if(ERR_NOT_IN_RANGE==creep.build(construction_site[0])){
creep.moveTo(construction_site[0]);
}
}
}
}