These are chat archives for highfidelity/hifi

28th
Nov 2016
Polyrhythm
@Polyrhythm
Nov 28 2016 21:56
hey y'all what's the best way to debug from within an entity script?
(function() {
  this.whatever = function() {
    print('hello'); // <== where does this go?
  };
})
Ryan Huffman
@huffman
Nov 28 2016 23:01
Are you wondering where you can see the output @Polyrhythm ?
Polyrhythm
@Polyrhythm
Nov 28 2016 23:02
yep, it doesn't appear in my logs in my appdata either
also i am submitting my first PR :) highfidelity/hifi#9120
workring on figuring out how your unit tests run
Ryan Huffman
@huffman
Nov 28 2016 23:03
Is that the actual script or was that just an example?
Maybe it isn't reaching your print statement ?
Polyrhythm
@Polyrhythm
Nov 28 2016 23:03
perhaps, lemme pull up a real example
(function() {
    var HOVER_SPEED = 0.1;
    var time;
    function TestEntity() {}

    TestEntity.prototype.update = function(deltaTime) {
        var pos = Entities.getEntityProperties(this.entityId, ['position']).position;
        time = new Date().getTime();
        print('hot dang'); // <== this guy
        Entities.editEntity(this.entityId, {
            position: {
                x: pos.x,
                y: pos.y + Math.sin(time * deltaTime * HOVER_SPEED),
                z: pos.z,
            } 
        });
    };

    TestEntity.prototype.preload = function(id) {
        this.entityId = id;
        print("preload");

        Script.update.connect(this.update);
    };

    TestEntity.prototype.unload = function() {
        print("unload");
    };

    return new TestEntity();
})
print statement in the update fn
i'm using some of your undocumented api here so
/shrug
Ryan Huffman
@huffman
Nov 28 2016 23:58
@Polyrhythm I would try a couple things
First, I would put the print at the top to make sure the function is being called
and ... (one sec)
Polyrhythm
@Polyrhythm
Nov 28 2016 23:59
at the top meaning all the way outside the scope of the self-initializing fn?