AFRLme

animated hh:mm:ss countdown timer (antiquated) [VS] (works)

Dec 20th, 2012
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.91 KB | None | 0 0
  1. -- * notes * --
  2. -- this script allows you to setup a variable based live fully animated countdown timer display!
  3. -- currently you can set up to a maximum of 59 minutes & 59 seconds ...
  4. -- it wouldn't be to hard to add a couple of extra functions for displaying 24 hours & an extra one to count day 1,2,3 etc.
  5. -- how to use: execute a script  > startCountdown(minute[tens], minute[singular], seconds[tens], seconds[singular])
  6. -- example: "startCountdown(0, 1, 3, 0)" ='s 1 minute & 30 seconds.
  7.  
  8. -- * local variable defaults for timer display value   * --
  9. local sec_sin_val = 0
  10. local sec_dbl_val = 0
  11. local min_sin_val = 0
  12. local min_dbl_val = 0
  13.  
  14. -- * local variables for getting single second digit animations * --
  15. local ss = getObject('Scenes[Scene_001].SceneObjects[single_sec_digit]')
  16. local ss0 = ss:getObject('.ObjectAnimations[single_0]')
  17. local ss1 = ss:getObject('.ObjectAnimations[single_1]')
  18. local ss2 = ss:getObject('.ObjectAnimations[single_2]')
  19. local ss3 = ss:getObject('.ObjectAnimations[single_3]')
  20. local ss4 = ss:getObject('.ObjectAnimations[single_4]')
  21. local ss5 = ss:getObject('.ObjectAnimations[single_5]')
  22. local ss6 = ss:getObject('.ObjectAnimations[single_6]')
  23. local ss7 = ss:getObject('.ObjectAnimations[single_7]')
  24. local ss8 = ss:getObject('.ObjectAnimations[single_8]')
  25. local ss9 = ss:getObject('.ObjectAnimations[single_9]')
  26.  
  27. -- * local variables for getting double second digit animations * --
  28. local ds = getObject('Scenes[Scene_001].SceneObjects[double_sec_digit]')
  29. local ds0 = ds:getObject('.ObjectAnimations[double_0]')
  30. local ds1 = ds:getObject('.ObjectAnimations[double_1]')
  31. local ds2 = ds:getObject('.ObjectAnimations[double_2]')
  32. local ds3 = ds:getObject('.ObjectAnimations[double_3]')
  33. local ds4 = ds:getObject('.ObjectAnimations[double_4]')
  34. local ds5 = ds:getObject('.ObjectAnimations[double_5]')
  35.  
  36. -- * local variables for getting single minute digit animations * --
  37. local sm = getObject('Scenes[Scene_001].SceneObjects[single_min_digit]')
  38. local sm0 = sm:getObject('.ObjectAnimations[single_0]')
  39. local sm1 = sm:getObject('.ObjectAnimations[single_1]')
  40. local sm2 = sm:getObject('.ObjectAnimations[single_2]')
  41. local sm3 = sm:getObject('.ObjectAnimations[single_3]')
  42. local sm4 = sm:getObject('.ObjectAnimations[single_4]')
  43. local sm5 = sm:getObject('.ObjectAnimations[single_5]')
  44. local sm6 = sm:getObject('.ObjectAnimations[single_6]')
  45. local sm7 = sm:getObject('.ObjectAnimations[single_7]')
  46. local sm8 = sm:getObject('.ObjectAnimations[single_8]')
  47. local sm9 = sm:getObject('.ObjectAnimations[single_9]')
  48.  
  49. -- * local variables for getting double minute digit animations * --
  50. local dm = getObject('Scenes[Scene_001].SceneObjects[double_min_digit]')
  51. local dm0 = dm:getObject('.ObjectAnimations[double_0]')
  52. local dm1 = dm:getObject('.ObjectAnimations[double_1]')
  53. local dm2 = dm:getObject('.ObjectAnimations[double_2]')
  54. local dm3 = dm:getObject('.ObjectAnimations[double_3]')
  55. local dm4 = dm:getObject('.ObjectAnimations[double_4]')
  56. local dm5 = dm:getObject('.ObjectAnimations[double_5]')
  57.  
  58. -- * local variable which contains the condition for timer_is_on? * --
  59. local cond = getObject('Scenes[Scene_001].SceneConditions[timer_is_on?]')
  60.  
  61. -- * local variable which contains the action to check the current time! * --
  62. local act = getObject('Characters[Protagonist].CharacterActions[check_time]')
  63.  
  64. -- * start variable countdown * --
  65. function startCountdown(mdv, msv, sdv, ssv)
  66.  if ssv > 9 then ssv = 9 end
  67.  if sdv > 5 then sdv = 5 end
  68.  if msv > 9 then msv = 9 end
  69.  if mdv > 5 then mdv = 5 end
  70.  -- * --
  71.  local sec_sin = ss:getObject('.ObjectAnimations[single_' .. ssv .. ']')
  72.  local sec_dbl = ds:getObject('.ObjectAnimations[double_' .. sdv .. ']')
  73.  local min_sin = sm:getObject('.ObjectAnimations[single_' .. msv .. ']')
  74.  local min_dbl = dm:getObject('.ObjectAnimations[double_' .. mdv .. ']')
  75.  -- * --
  76.  sec_sin_val = ssv
  77.  sec_dbl_val = sdv
  78.  min_sin_val = msv
  79.  min_dbl_val = mdv
  80.  -- * --
  81.  stopAnimation(ss0)
  82.  stopAnimation(ds0)
  83.  stopAnimation(sm0)
  84.  stopAnimation(dm0)
  85.  -- * --
  86.  startAnimation(sec_sin)
  87.  startAnimation(sec_dbl)
  88.  startAnimation(min_sin)
  89.  startAnimation(min_dbl)
  90.  -- * --
  91.  startAction(act)
  92.  -- * --
  93.  print('timer has been set to ' .. mdv .. msv .. ':' .. sdv .. ssv .. '!')
  94.  print('timer has been started!')
  95. end
  96.  
  97. -- * check single second digit * --
  98. function check_ssd_val()
  99.  if sec_sin_val >= 9 then
  100.   sec_sin_val = 8
  101.   stopAnimation(ss9)
  102.   startAnimation(ss8)
  103.  else
  104.  if sec_sin_val == 8 then
  105.   sec_sin_val = 7
  106.   stopAnimation(ss8)
  107.   startAnimation(ss7)
  108.  else
  109.  if sec_sin_val == 7 then
  110.   sec_sin_val = 6
  111.   stopAnimation(ss7)
  112.   startAnimation(ss6)
  113.  else
  114.  if sec_sin_val == 6 then
  115.   sec_sin_val = 5
  116.   stopAnimation(ss6)
  117.   startAnimation(ss5)
  118.  else
  119.  if sec_sin_val == 5 then
  120.   sec_sin_val = 4
  121.   stopAnimation(ss5)
  122.   startAnimation(ss4)
  123.  else
  124.  if sec_sin_val == 4 then
  125.   sec_sin_val = 3
  126.   stopAnimation(ss4)
  127.   startAnimation(ss3)
  128.  else
  129.  if sec_sin_val == 3 then
  130.   sec_sin_val = 2
  131.   stopAnimation(ss3)
  132.   startAnimation(ss2)
  133.  else
  134.  if sec_sin_val == 2 then
  135.   sec_sin_val = 1
  136.   stopAnimation(ss2)
  137.   startAnimation(ss1)
  138.  else
  139.  if sec_sin_val == 1 then
  140.   sec_sin_val = 0
  141.   stopAnimation(ss1)
  142.   startAnimation(ss0)
  143.   else
  144.   if sec_sin_val == 0 then
  145.    if sec_dbl_val + min_dbl_val + min_sin_val > 0 then
  146.     sec_sin_val = 9
  147.     stopAnimation(ss0)
  148.     startAnimation(ss9)
  149.     check_dsd_val()
  150.    else
  151.     cond:setValue(VConditionValue, false)
  152.     print('timer has finished counting down!')
  153.    end
  154.   end end end end end end end end end end
  155. end
  156.  
  157. -- * check double second digit * --
  158. function check_dsd_val()
  159.  if sec_dbl_val >= 5 then
  160.   sec_dbl_val = 4
  161.   stopAnimation(ds5)
  162.   startAnimation(ds4)
  163.  else
  164.  if sec_dbl_val == 4 then
  165.   sec_dbl_val = 3
  166.   stopAnimation(ds4)
  167.   startAnimation(ds3)
  168.  else
  169.  if sec_dbl_val == 3 then
  170.   sec_dbl_val = 2
  171.   stopAnimation(ds3)
  172.   startAnimation(ds2)
  173.  else
  174.  if sec_dbl_val == 2 then
  175.   sec_dbl_val = 1
  176.   stopAnimation(ds2)
  177.   startAnimation(ds1)
  178.  else
  179.  if sec_dbl_val == 1 then
  180.   sec_dbl_val = 0
  181.   stopAnimation(ds1)
  182.   startAnimation(ds0)
  183.   else
  184.   if sec_dbl_val == 0 then
  185.    if min_dbl_val + min_sin_val > 0 then
  186.     sec_dbl_val = 5
  187.     stopAnimation(ds0)
  188.     startAnimation(ds5)
  189.     check_smd_val()
  190.    end
  191.   end end end end end end
  192. end
  193.  
  194. -- * check single minute digit * --
  195. function check_smd_val()
  196.  if min_sin_val >= 9 then
  197.   min_sin_val = 8
  198.   stopAnimation(sm9)
  199.   startAnimation(sm8)
  200.  else
  201.  if min_sin_val == 8 then
  202.   min_sin_val = 7
  203.   stopAnimation(sm8)
  204.   startAnimation(sm7)
  205.  else
  206.  if min_sin_val == 7 then
  207.   min_sin_val = 6
  208.   stopAnimation(sm7)
  209.   startAnimation(sm6)
  210.  else
  211.  if min_sin_val == 6 then
  212.   min_sin_val = 5
  213.   stopAnimation(sm6)
  214.   startAnimation(sm5)
  215.  else
  216.  if min_sin_val == 5 then
  217.   min_sin_val = 4
  218.   stopAnimation(sm5)
  219.   startAnimation(sm4)
  220.  else
  221.  if min_sin_val == 4 then
  222.   min_sin_val = 3
  223.   stopAnimation(sm4)
  224.   startAnimation(sm3)
  225.  else
  226.  if min_sin_val == 3 then
  227.   min_sin_val = 2
  228.   stopAnimation(sm3)
  229.   startAnimation(sm2)
  230.  else
  231.  if min_sin_val == 2 then
  232.   min_sin_val = 1
  233.   stopAnimation(sm2)
  234.   startAnimation(sm1)
  235.  else
  236.  if min_sin_val == 1 then
  237.   min_sin_val = 0
  238.   stopAnimation(sm1)
  239.   startAnimation(sm0)
  240.   else
  241.   if min_sin_val == 0 then
  242.    if min_dbl_val > 0 then
  243.     min_sin_val = 9
  244.     stopAnimation(sm0)
  245.     startAnimation(sm9)
  246.     check_dmd_val()
  247.    end
  248.   end end end end end end end end end end
  249. end
  250.  
  251. -- * check double minute digit * --
  252. function check_dmd_val()
  253.  if min_dbl_val >= 5 then
  254.   min_dbl_val = 4
  255.   stopAnimation(dm5)
  256.   startAnimation(dm4)
  257.  else
  258.  if min_dbl_val == 4 then
  259.   min_dbl_val = 3
  260.   stopAnimation(dm4)
  261.   startAnimation(dm3)
  262.  else
  263.  if min_dbl_val == 3 then
  264.   min_dbl_val = 2
  265.   stopAnimation(dm3)
  266.   startAnimation(dm2)
  267.  else
  268.  if min_dbl_val == 2 then
  269.   min_dbl_val = 1
  270.   stopAnimation(dm2)
  271.   startAnimation(dm1)
  272.  else
  273.  if min_dbl_val == 1 then
  274.   min_dbl_val = 0
  275.   stopAnimation(dm1)
  276.   startAnimation(dm0)
  277.   end end end end end
  278. end
Advertisement
Add Comment
Please, Sign In to add comment