【问题标题】:Strange survival mode only error奇怪的生存模式只有错误
【发布时间】:2015-05-14 12:03:38
【问题描述】:
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

这很奇怪,因为它在模拟模式下工作得很好,但在生存模式下却不行。

【问题讨论】:

  • 您是否故意在您的if 条件中使用= 而不是==?我对此表示怀疑。
  • 大声笑我一直在这样做,但还是一样。并且在模拟模式下运行得很好,为什么会在生存中抛出错误?

标签: javascript screeps


【解决方案1】:

Screeps API 昨天已更改:changelog

您现在必须使用findClosest(FIND_SOURCES) 而不是findClosest(Game.SOURCES)

【讨论】:

  • 修复了它。为什么它仍然在模拟模式下工作?
猜你喜欢
  • 1970-01-01
  • 2016-05-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-23
  • 1970-01-01
  • 2016-03-15
  • 1970-01-01
相关资源
最近更新 更多