Created
September 1, 2015 01:06
-
-
Save avdg/b81bc3d08f36905a7116 to your computer and use it in GitHub Desktop.
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
diff --git a/extensions/tools/commands/creepClone.js b/extensions/tools/commands/creepClone.js | |
index 3a02c7f..908da15 100644 | |
--- a/extensions/tools/commands/creepClone.js | |
+++ b/extensions/tools/commands/creepClone.js | |
@@ -7,11 +7,11 @@ var duplicateCreep = function (creep, priority, silence) { | |
silence = silence === true; | |
// Find and add to queue | |
- if (typeof creep.memory.spawn === "string") { | |
- spawn = Game.getObjectById(creep.memory.spawn).name; | |
+ if (typeof creep.memory.spawn === "string" && Game.spawns[creep.memory.spawn] instanceof Spawn) { | |
+ spawn = Game.getObjectById(creep.memory.spawn); | |
} | |
- if (typeof spawn !== 'string') { | |
+ if (!(spawn instanceof Spawn)) { | |
Memory[priority].push({ | |
role: creep.memory.role, memory: _.cloneDeep(creep.memory) | |
}); | |
@@ -23,15 +23,15 @@ var duplicateCreep = function (creep, priority, silence) { | |
return; | |
} | |
- if (!Memory.spawns[spawn]) Memory.spawns[spawn] = {}; | |
- if (!Memory.spawns[spawn][priority]) Memory.spawns[spawn][priority] = []; | |
+ if (!Memory.spawns[spawn.name]) Memory.spawns[spawn.name] = {}; | |
+ if (!Memory.spawns[spawn.name][priority]) Memory.spawns[spawn.name][priority] = []; | |
- Memory.spawns[spawn][priority].push({ | |
+ Memory.spawns[spawn.name][priority].push({ | |
role: creep.memory.role, memory: _.cloneDeep(creep.memory) | |
}); | |
if (!silence) { | |
- console.log("Added " + (creep.name || creep.memory.role) + " to " + priority + " at spawn " + spawn); | |
+ console.log("Added " + (creep.name || creep.memory.role) + " to " + priority + " at spawn " + spawn.name); | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment