I donβt know how to do this, but I created a wrapper class similar to this:
You created a function to call memory and try to use its s property. See below: var _ = require ("lodash");
function MyCreep(creep){
this.creep = creep;
this.memoryProp = creep.memory;
}
MyCreep.prototype.memoryFunc = function(){
return this.creep.memory;
};
MyCreep.prototype.moveTo = function(target){
this.creep.moveTo(target);
}
MyCreep.prototype.myFunction = function(target){
}
Therefore, when I need to deal with creep, I do:
var myCreeps = [];
for (var creep in Game.creeps){
creep.memory.role = "hello memory";
var myCreep = new MyCreep(Game.creeps[creep]);
myCreeps.push(myCreep); ;
console.log("original creep memory: "+creep.memory.role);
console.log("my creep memory func: "+myCreep.memoryFunc().role);
console.log("my creep memory prop: "+myCreep.memoryProp.role);
}
or
var myCreeps = [];
_.forEach(Game.creeps, function(creep){
var myCreep = new MyCreep(creep);
myCreeps.push(myCreep);
});
and then process the local myCreeps files.
source
share