15 lines
488 B
JavaScript
15 lines
488 B
JavaScript
module.exports = {
|
|
run(creep) {
|
|
//分配source
|
|
if (creep.carry.energy < creep.carryCapacity) {
|
|
let sources = creep.room.find(FIND_SOURCES);
|
|
if (creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
|
|
creep.moveTo(sources[0]);
|
|
}
|
|
} else {
|
|
if (creep.transfer(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
|
creep.moveTo(Game.spawns['Spawn1']);
|
|
}
|
|
}
|
|
}
|
|
} |