检查LHS中的对象属性

时间:2016-05-09 17:02:32

标签: clips

我需要检查LHS中o对象属性的值是否存在。

(defrule check-property
    ?room <- (object (is-a ROOM))
    (integerp (send ?room get-property))   ; #1
    =>
    (printout ?*debug-print* "Room " ?room " has property"  crlf))

但在我看来,#1未在LHS中评估。相反,如果我把它放在RHS中,它返回TRUE。 我哪里错了?

THX, NIC

1 个答案:

答案 0 :(得分:2)

使用测试条件元素评估规则的LHS中的表达式:

var material = new THREE.MeshLambertMaterial({color: 0xAABBAA, skinning: true});
var maxLength = Math.max(geom.vertices[0].y, geom.vertices[geom.vertices.length-1].y);

        // calculate skinweigths
        for(var i = 0; i < MAXRESOLUTION; i++){
            var skinIndex = geom.vertices[i].y > 0? 1 : 0;
            var skinWeight = Math.abs(geom.vertices[i].y/maxLength);

            geom.skinIndices.push( new THREE.Vector4( skinIndex, skinIndex + 1, 0, 0 ) );
            geom.skinWeights.push( new THREE.Vector4( 1 - skinWeight, skinWeight, 0, 0 ) );
        }

        // create new mesh
        var newMesh = new THREE.SkinnedMesh(geom, material);

        skeleton.bones[0].position.y = geom.vertices[0].y;
        skeleton.bones[1].position.y = -geom.vertices[0].y;

        // combine mesh with skeleton
        var root = skeleton.bones[0];
        newMesh.add(root);

        newMesh.bind(skeleton);

最好通过匹配槽而不是使用槽访问器来显式检索槽值,因为这将导致在槽值更改时重新评估条件:

(defrule check-property
    ?room <- (object (is-a ROOM))
    (test (integerp (send ?room get-property)))
    =>
    (printout ?*debug-print* "Room " ?room " has property"  crlf))