Created
September 23, 2015 22:20
-
-
Save Hernanduer/24a022efaa5795b50326 to your computer and use it in GitHub Desktop.
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
findNearestStorage: function(creep) { | |
var pref = undefined; | |
if (creep.room.storage != undefined) | |
pref = creep.room.storage; | |
for (var link in creep.room.memory.energy.linkSources) { | |
var l = Game.getObjectById(link); | |
if (l != null && creep.pos.getRangeTo(pref) > creep.pos.getRangeTo(l)) | |
pref = l; | |
} | |
if (pref == undefined || pref == null) | |
return this.findClosest(creep, creep.room.memory.structs.spawns, true); | |
else | |
return pref.id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment