Skip to content

Instantly share code, notes, and snippets.

@kbakdev
Created May 14, 2022 17:35
Show Gist options
  • Save kbakdev/6ae64c73aaec7e98f0b7a72a4f59fcf0 to your computer and use it in GitHub Desktop.
Save kbakdev/6ae64c73aaec7e98f0b7a72a4f59fcf0 to your computer and use it in GitHub Desktop.
set behavior to 2 screeps
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