I’m trying to use scripting to have my Instructions (Tap to Place) show when Runtime is greater than 3 seconds. I access Runtime with “let Runtime = Time.ms”.
I have Diagnostics.watch showing Runtime and also Runtime.ge(3000), and both are working correctly. (I.e., Runtime greater than 3 seconds only becomes true when Runtime > 3000).
Problem occurs here:
I have both an Instructions and a Diagnostics.log("Runtime greater than 30) nested under an if-statement that only should run if Runtime >3000, which is captured by the variable “RuntimeGreaterThan3” (see code pasted below).
However, my instructions “Tap to Place” and also the Diagnostics.log(“Runtime greater than 30”) is showing immediately, even when “RuntimeGreaterThan3” is much less than 3 seconds (as shown by the screenshot). Would anyone be able to help me understand why my if-statement is being executed when the variable “RuntimeGreaterThan3” is showing as false under Diagonistics.watch?
MY SCRIPT:
const Scene = require(‘Scene’);
const Instruction = require(‘Instruction’);
const Diagnostics = require(‘Diagnostics’);
const Time = require(‘Time’);
;(async function () { // Enables async/await in JS [part 1]
let Runtime = Time.ms
let RuntimeGreaterThan3 = Runtime.ge(3000)
Diagnostics.watch(‘Runtime (ms)’, Runtime)
Diagnostics.watch(‘Runtime greater than 3 seconds’, RuntimeGreaterThan3)
if (RuntimeGreaterThan3) {
Diagnostics.log(‘Runtime greater than 3 seconds’)
Instruction.bind(true, ‘tap_to_place’);
}
})();
Here’s the screenshot showing that Runtime and RuntimeGreaterThan3 are being tracked correctly, but the if-statement is executing, even when RuntimeGreaterThan3 is false.