Number vs decimal issue


#1

In your material I tend to get the impression that your JavaScript is fine with ‘number’ for all data-types while dividing. So why does this fail then?

EventReceiver.attributes.add('perfHast_tester',{    type: 'number',    default: 0});
EventReceiver.attributes.add('perfHT_count',{    type: 'number',    default: 0});
EventReceiver.attributes.add('perf_AnimRes',{    type: 'number',    default: 0});

EventReceiver.prototype.update = function(dt) {     
    //perfHast_tester   
    console.log('dt: '+dt + 'htcnt'+this.perfHT_count);
    if(this.perfHT_count<100){ this.perfHT_count++;
        this.perfHast_tester+=dt;
    }
     if(this.perfHT_count===99){console.log('perf_teshst: '+this.perfHast_tester+ ' animCurrTime: ' +this.entity.animation.currentTime);
        this.perfHast_tester/=99;         this.perf_AnimRes/=0.0166; console.log('perf_AnimRes1111: '+this.perf_AnimRes);
     }      
};

the output for ‘this.perf_AnimRes’ always give me ‘0’ no matter the debugging


#2

Where is this.perf_AnimRes value set? In the code snippet here, it starts at 0 and never changes?


#3

Wait - couldn’t see the wood for trees :-/

This alteration still doesn’t work though:

     if(this.perfHT_count===99){console.log('perf_teshst: '+this.perfHast_tester+ ' animCurrTime: ' +this.entity.animation.currentTime);
        this.perfHast_tester/=99;         this.perf_AnimRes=this.perfHast_tester/0.0166; console.log('perf_AnimRes1111: '+this.perf_AnimRes);
     }    

In console:

perf_teshst: 3.2528370000000035 animCurrTime: 4.715413200000001
event-receiver.js?id=16684320&branchId=c32649f1-d5bb-4f31-8a39-578899a09d91:40 perf_AnimRes1111: 0

#4

ok finally worked after going into the correct scene to update the script within that (cumbersome though, to be forced to do all those updates :-/ )

But thx anyways :slight_smile: