Created
September 23, 2015 22:20
-
-
Save Hernanduer/d54a72fb551d05edfa23 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