Advertisement
nrzmalik

Timer in Articulate Storyline

Oct 15th, 2024
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.89 KB | Source Code | 0 0
  1. var player = GetPlayer();
  2. var totalMinutes = player.GetVar("SlTimer");
  3. var totalTimeInSeconds = totalMinutes * 60;
  4. if (typeof window.timerInterval === 'undefined') {
  5.     function startCountdown() {
  6.         window.timerInterval = setInterval(function() {
  7.             var minutes = Math.floor(totalTimeInSeconds / 60);
  8.             var seconds = totalTimeInSeconds % 60;
  9.             var formattedMinutes = minutes < 10 ? "0" + minutes : minutes;
  10.             var formattedSeconds = seconds < 10 ? "0" + seconds : seconds;
  11.             player.SetVar("TimerCount", formattedMinutes + ":" + formattedSeconds);
  12.             totalTimeInSeconds--;
  13.             if (totalTimeInSeconds < 0) {
  14.                 clearInterval(window.timerInterval);
  15.                 delete window.timerInterval;
  16.                 player.SetVar("TimerEnable",false)
  17.             }
  18.         }, 1000);
  19.     }
  20.     startCountdown();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement