Forum Discussion
AmyGtt
2 months agoCommunity Member
Variable not changing button state
I've got a pretty complicated situation.
I am creating a compliance course that a user must be in each module for 30 minutes. There are 9 modules. When the course begins, they can't leave the co...
SamHill
2 months agoSuper Hero
Hi AmyGtt I think your best approach would be to not use the %correctedElapsedTime% variable as the trigger. As you said, it is a text variable, and so you cannot use the >= operator to determine if 30 minutes has been met.
You could just have a Boolean variable, for example %timesUp% initialialised as FALSE. Then, on your main timeline you could trigger your Button - 2 "Next" to normal when it is updated to TRUE.
You would then just need to add some more JS to to trigger that change.
// Update elapsed time
function updateElapsedTime() {
if (isTabActive && isFocused) {
elapsedTime++;
var minutes = Math.floor(elapsedTime / 60);
var seconds = elapsedTime % 60;
var formattedTime = minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
player.SetVar("correctedElapsedTime", formattedTime);
// ** NEW SCRIPT HERE ** //
// Is time up?
if(elapsedTime >= 1800000) player.SetVar("timesUp",true);
}
}