blob: a4fc27f91a520484c8e722586cb7a3cb02765c4b (
plain) (
blame)
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
|
module.exports = {
run: (creep) => {
if (creep.memory.state === "building") {
if (creep.carry.energy > 0) {
const targets = creep.room.find(FIND_CONSTRUCTION_SITES);
if (targets.length) {
if (creep.build(targets[0]) == ERR_NOT_IN_RANGE) {
move(creep, targets[0]);
}
}
} else {
creep.memory.state = "collecting";
}
} else {
if (creep.carry.energy < creep.carryCapacity) {
// still filling up
const spawn = Game.spawns['Initial'];
if (creep.transfer(spawn, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
move(creep, spawn);
}
} else {
creep.memory.state = "building";
}
}
}
};
|