if(creep === Game.creeps["Worker0"])
{
var sources = creep.pos.findClosest(Game.SOURCES);
creep.moveTo(24,29);
creep.harvest(sources);
creep.transferEnergy(Game.creeps["Transport0"]);
}
if(creep === Game.creeps["Worker1"])
{
var sources = creep.pos.findClosest(Game.SOURCES);
creep.moveTo(25,29);
creep.harvest(sources);
creep.transferEnergy(Game.creeps["Transport0"]);
}
I get below error:
TypeError: Cannot read property 'forEach' of undefined
at RoomPosition.findClosest (/opt/engine/dist/game/rooms.js:843:23)
at module.exports (harvester:7:30)
at main:24:11
It is weird because it works just fine in simulation mode but not in survival.
The Screeps API has been changed yesterday: changelog.
You have to use findClosest(FIND_SOURCES)
now instead of findClosest(Game.SOURCES)
.