diff options
| -rw-r--r-- | src/role.builder.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/role.builder.js b/src/role.builder.js index 8c7fc6b..f243eac 100644 --- a/src/role.builder.js +++ b/src/role.builder.js @@ -4,6 +4,7 @@ module.exports = { run: (creep) => { if (creep.memory.state === "building") { if (creep.carry.energy > 0) { + // still building const targets = creep.room.find(FIND_CONSTRUCTION_SITES); if (targets.length) { if (creep.build(targets[0]) == ERR_NOT_IN_RANGE) { @@ -11,16 +12,18 @@ module.exports = { } } } else { + // just finished building 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) { + if (creep.withdraw(spawn, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { util.move(creep, spawn); } } else { + // just finished filling up creep.memory.state = "building"; } } |
