screep/picker.js

17 lines
540 B
JavaScript
Raw Normal View History

2020-10-18 22:00:22 +08:00
//只收集,不运输
module.exports = {
run(creep) {
2020-10-20 17:09:06 +08:00
// let sources = creep.room.find(FIND_SOURCES);
let working_target_id=creep.working_target_id;
let working_target=Game.getObjectById(working_target_id);
let Re_code=creep.harvest(working_target);
2020-10-18 22:00:22 +08:00
if ( Re_code== ERR_NOT_IN_RANGE) {
2020-10-20 17:09:06 +08:00
creep.moveTo(working_target);
2020-10-18 22:00:22 +08:00
}else{
if(OK==Re_code){
2020-10-20 17:09:06 +08:00
creep.harvest(working_target);
2020-10-18 22:00:22 +08:00
creep.drop(RESOURCE_ENERGY);
}
}
}
}