diff options
| author | Tom Harley | 2018-06-26 16:15:16 +0100 |
|---|---|---|
| committer | Tom Harley | 2018-06-26 16:15:16 +0100 |
| commit | 98aea93a3c337c38477701b06d98ebf2f83b0fc3 (patch) | |
| tree | 0a04a50e85d5bf499a906b148e8dcd8783aa1895 /src/role.harvester.js | |
| parent | Add hard-coded spawn reference (diff) | |
| download | screeps-ai-98aea93a3c337c38477701b06d98ebf2f83b0fc3.tar.gz screeps-ai-98aea93a3c337c38477701b06d98ebf2f83b0fc3.zip | |
Unify movement commands
Diffstat (limited to 'src/role.harvester.js')
| -rw-r--r-- | src/role.harvester.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/role.harvester.js b/src/role.harvester.js index 4d13dd7..e08db08 100644 --- a/src/role.harvester.js +++ b/src/role.harvester.js @@ -1,15 +1,17 @@ +const move = require('creep'); + module.exports = { run: (creep) => { if (creep.carry.energy < creep.carryCapacity) { // just use the first source for now const source = creep.pos.findClosestByPath(FIND_SOURCES); if (creep.harvest(source) == ERR_NOT_IN_RANGE) { - creep.moveTo(source); + move(creep, source); } } else { const spawn = Game.spawns['Initial']; if (creep.transfer(spawn, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { - creep.moveTo(spawn); + move(creep, spawn); } } } |
