Jbz797
Jbz797

Reputation: 13

Logical operators in the filter option

How to use two arguments in a filter?

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

Because my filter only considers the argument 'source1'...

Upvotes: 0

Views: 710

Answers (1)

Anima-t3d
Anima-t3d

Reputation: 3565

Just make sure you add the comparison in the second part as well object.id != source2

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

Upvotes: 1

Related Questions