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"]);
}
我得到以下错误:
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
这很奇怪,因为它在模拟模式下工作得很好,但在生存方面却没有。
答案 0 :(得分:0)
Screeps API昨天已更改:changelog。
您现在必须使用findClosest(FIND_SOURCES)
而不是findClosest(Game.SOURCES)
。