-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrole.miner.js
More file actions
27 lines (26 loc) · 1.01 KB
/
role.miner.js
File metadata and controls
27 lines (26 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var roleMiner = {
// Game.getObjectById('2f14d2682be9b195dc609b1c').pos.findClosestByRange(FIND_STRUCTURES, {filter: (structure) => {return (structure.structureType == STRUCTURE_CONTAINER)}});
run: function (creep) {
if (creep.memory.upgrading) {
var targets = creep.room.find(FIND_STRUCTURES, {filter: (structure) => {return (structure.structureType == STRUCTURE_CONTAINER) &&
structure.energy < structure.energyCapacity;}
});
if (targets.length > 0) {
if (creep.transfer(targets[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(targets[0]);
}
}
else
{
require('role.builder').run(creep);
}
}
else {
var source = Game.getObjectById(creep.memory.sourceId);
if (creep.harvest(source) == ERR_NOT_IN_RANGE) {
creep.moveTo(source);
}
}
}
};
module.exports = roleMiner;