Last active
August 29, 2015 14:27
-
-
Save new-guy/17707b14c345632ab9c0 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
TypeError: endNodes.objects.forEach is not a function | |
at RoomPosition.findClosest (/opt/engine/dist/game/rooms.js:771:24) | |
at getNonEmptyContainer (roadman:55:26) | |
at getMoreEnergy (roadman:22:22) | |
at module.exports (roadman:8:9) | |
at main:66:9 | |
function getNonEmptyContainer() | |
{ | |
var nonFullArray = creep.room.getNonEmptyContainerArray(); | |
//var nonFullArray = roomTools.getNonEmptyContainerArray(creep); | |
return creep.pos.findClosest(nonFullArray); | |
} | |
Room.prototype.getNonEmptyContainerArray = function(room) | |
{ | |
//Check to see if we have nonfull Storage | |
var storage = this.find(FIND_MY_STRUCTURES, {filter: {'structureType': STRUCTURE_STORAGE}})[0]; | |
if(typeof storage != 'undefined' && storage.store.energy > 0) return storage; | |
//Then look at everything else | |
var containerArray = this.find(FIND_MY_STRUCTURES); | |
var spawn = this.find(FIND_MY_SPAWNS)[0]; | |
if(spawn != null && typeof spawn != 'undefined') containerArray.push(spawn); | |
if(containerArray.length == 0) | |
{ | |
conatinerArray = getGlobalStorage(); | |
} | |
var nonFullArray = []; | |
for(var i = 0; i < containerArray.length; i++) | |
{ | |
var container = containerArray[i]; | |
if(container.energy > 0) | |
{ | |
nonFullArray.push(container); | |
} | |
} | |
return nonFullArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment