Fascinating game!
Looking for an example of how to persist a reference to a particular energy source in a creep's memory. Seems that storing the actual source object won't work(?).
You can't store object instances, but you can store their IDs.
if(!creep.memory.targetSourceId) {
var source = creep.pos.findNearest(Game.SOURCES_ACTIVE);
creep.memory.targetSourceId = source.id;
}
And then you can use Game.getObjectById()
to find this particular source.
var source = Game.getObjectById(creep.memory.targetSourceId);
creep.moveTo(source);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With