Created
May 14, 2022 17:35
-
-
Save kbakdev/6ae64c73aaec7e98f0b7a72a4f59fcf0 to your computer and use it in GitHub Desktop.
set behavior to 2 screeps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.loop = function () { | |
for(var name in Game.creeps) { | |
var creep = Game.creeps[name]; | |
if(creep.store.getFreeCapacity() > 0) { | |
var sources = creep.room.find(FIND_SOURCES); | |
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) { | |
creep.moveTo(sources[0]); | |
} | |
} | |
else { | |
if(creep.transfer(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { | |
creep.moveTo(Game.spawns['Spawn1']); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment