【问题标题】:Logical operators in the filter option过滤器选项中的逻辑运算符
【发布时间】:2015-01-09 05:52:07
【问题描述】:

如何在过滤器中使用两个参数?

var source3 = Game.spawns.Spawn1.pos.findClosest(Game.SOURCES_ACTIVE, {
    filter: function(object) {
        return object.id != source1 && source2;
    }
}).id;

因为我的过滤器只考虑参数'source1'...

【问题讨论】:

    标签: javascript screeps


    【解决方案1】:

    请确保您在第二部分中也添加了比较object.id != source2

    var source3 = Game.spawns.Spawn1.pos.findClosest(Game.SOURCES_ACTIVE, {
        filter: function(object) {
            return object.id != source1 && object.id != source2;
        }
    }).id;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-03
      • 1970-01-01
      • 2020-12-20
      相关资源
      最近更新 更多