Screeps Wiki
Advertisement

function (target) {

   if (!this.my) {
     return C.ERR_NOT_OWNER;
   }
   if (data(this.id).spawning) {
     return C.ERR_BUSY;
   }
   if (this.getActiveBodyparts(C.WORK) == 0) {
     return C.ERR_NO_BODYPART;
   }
   if (!target || !target.id || !register.sources[target.id] || !(target instanceof globals.Source)) {
     return C.ERR_INVALID_TARGET;
   }
   if (!target.energy) {
     return C.ERR_NOT_ENOUGH_ENERGY;
   }
   if (!target.pos.isNearTo(this.pos)) {
     return C.ERR_NOT_IN_RANGE;
   }
   intents[this.id] = intents[this.id] || {};
   intents[this.id].harvest = {id: target.id};
   return C.OK;
 }
Advertisement