summaryrefslogtreecommitdiff
path: root/src/role.upgrader.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/role.upgrader.js')
-rw-r--r--src/role.upgrader.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/role.upgrader.js b/src/role.upgrader.js
index 26ccdf6..baf8ffd 100644
--- a/src/role.upgrader.js
+++ b/src/role.upgrader.js
@@ -1,11 +1,13 @@
+// vim: tw=80 ts=2 sw=2 et
+
const util = require('creep');
module.exports = {
run: (creep) => {
if (creep.memory.state === "withdrawing") {
- const source = Game.spawns['Initial'];
+ const source = Game.spawns[creep.memory.spawned_from];
if (creep.withdraw(source, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
- util.move(creep, source);
+ creep.moveTo(source);
}
if (creep.carry.energy == creep.carryCapacity) {
creep.memory.state = "upgrading";
@@ -13,7 +15,7 @@ module.exports = {
} else {
const controller = creep.room.controller;
if (creep.upgradeController(controller) == ERR_NOT_IN_RANGE) {
- util.move(creep, controller, { range: 3 });
+ creep.moveTo(controller, { range: 3 });
}
if (creep.carry.energy == 0) {
creep.memory.state = "withdrawing";