Created
May 14, 2022 17:33
-
-
Save kbakdev/77b25f67ed147899838806a81829f5b7 to your computer and use it in GitHub Desktop.
Screeps Transfer Resource
This file contains hidden or 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 () { | |
var creep = Game.creeps['Harvester1']; | |
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