AFRLme

keeping Score [VS] (works)

Dec 19th, 2012
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.22 KB | None | 0 0
  1. -- * notes * --
  2. -- this was made as a separate script to be used to display a live score counter of the current times we have hit the "x" key in my button mash example demo!
  3.  
  4. -- in this script I show how we can separate numbers into columns; single digit(1's), double digit(10's), triple digit(100's) & so on by resetting the value back to zero each time we reach 9 & in turn calling the function to check the current value of the next digit level ...
  5.  
  6. -- for example: if single_digit_value == 9 then single_digit_value = 0 check_double_digit_value if double_digit_value == 0 then double_digit_value = double_digit_value +1 & so on & so on ...
  7.  
  8. -- you get the general idea; I think?
  9.  
  10. -- * local variables for single digit score* --
  11. local sd_value = 0
  12. local sd = getObject('Scenes[Scene_001].SceneObjects[single_digit_score]')
  13. local sd0 = sd:getObject('.ObjectAnimations[single_0]')
  14. local sd1 = sd:getObject('.ObjectAnimations[single_1]')
  15. local sd2 = sd:getObject('.ObjectAnimations[single_2]')
  16. local sd3 = sd:getObject('.ObjectAnimations[single_3]')
  17. local sd4 = sd:getObject('.ObjectAnimations[single_4]')
  18. local sd5 = sd:getObject('.ObjectAnimations[single_5]')
  19. local sd6 = sd:getObject('.ObjectAnimations[single_6]')
  20. local sd7 = sd:getObject('.ObjectAnimations[single_7]')
  21. local sd8 = sd:getObject('.ObjectAnimations[single_8]')
  22. local sd9 = sd:getObject('.ObjectAnimations[single_9]')
  23.  
  24. -- * single digit score * --
  25. function check_sd_score()
  26.  if sd_value == 0 then
  27.   sd_value = sd_value +1
  28.   stopAnimation(sd0)
  29.   startAnimation(sd1)
  30.  else
  31.  if sd_value == 1 then
  32.   sd_value = sd_value +1
  33.   stopAnimation(sd1)
  34.   startAnimation(sd2)
  35.  else
  36.  if sd_value == 2 then
  37.   sd_value = sd_value +1
  38.   stopAnimation(sd2)
  39.   startAnimation(sd3)
  40.  else
  41.  if sd_value == 3 then
  42.   sd_value = sd_value +1
  43.   stopAnimation(sd3)
  44.   startAnimation(sd4)
  45.  else
  46.  if sd_value == 4 then
  47.   sd_value = sd_value +1
  48.   stopAnimation(sd4)
  49.   startAnimation(sd5)
  50.  else
  51.  if sd_value == 5 then
  52.   sd_value = sd_value +1
  53.   stopAnimation(sd5)
  54.   startAnimation(sd6)
  55.  else
  56.  if sd_value == 6 then
  57.   sd_value = sd_value +1
  58.   stopAnimation(sd6)
  59.   startAnimation(sd7)
  60.  else
  61.  if sd_value == 7 then
  62.   sd_value = sd_value +1
  63.   stopAnimation(sd7)
  64.   startAnimation(sd8)
  65.  else
  66.  if sd_value == 8 then
  67.   sd_value = sd_value +1
  68.   stopAnimation(sd8)
  69.   startAnimation(sd9)
  70.  else
  71.  if sd_value == 9 then
  72.   sd_value = 0
  73.   stopAnimation(sd9)
  74.   startAnimation(sd0)
  75.   check_dd_score()
  76.  end end end end end end end end end end
  77. end
  78.  
  79. -- * local variables for double digit score* --
  80. local dd_value = 0
  81. local dd = getObject('Scenes[Scene_001].SceneObjects[double_digit_score]')
  82. local dd0 = dd:getObject('.ObjectAnimations[double_0]')
  83. local dd1 = dd:getObject('.ObjectAnimations[double_1]')
  84. local dd2 = dd:getObject('.ObjectAnimations[double_2]')
  85. local dd3 = dd:getObject('.ObjectAnimations[double_3]')
  86. local dd4 = dd:getObject('.ObjectAnimations[double_4]')
  87. local dd5 = dd:getObject('.ObjectAnimations[double_5]')
  88. local dd6 = dd:getObject('.ObjectAnimations[double_6]')
  89. local dd7 = dd:getObject('.ObjectAnimations[double_7]')
  90. local dd8 = dd:getObject('.ObjectAnimations[double_8]')
  91. local dd9 = dd:getObject('.ObjectAnimations[double_9]')
  92.  
  93. -- * double digit score * --
  94. function check_dd_score()
  95.  if dd_value == 0 then
  96.   dd_value = dd_value +1
  97.   stopAnimation(dd0)
  98.   startAnimation(dd1)
  99.  else
  100.  if dd_value == 1 then
  101.   dd_value = dd_value +1
  102.   stopAnimation(dd1)
  103.   startAnimation(dd2)
  104.  else
  105.  if dd_value == 2 then
  106.   dd_value = dd_value +1
  107.   stopAnimation(dd2)
  108.   startAnimation(dd3)
  109.  else
  110.  if dd_value == 3 then
  111.   dd_value = dd_value +1
  112.   stopAnimation(dd3)
  113.   startAnimation(dd4)
  114.  else
  115.  if dd_value == 4 then
  116.   dd_value = dd_value +1
  117.   stopAnimation(dd4)
  118.   startAnimation(dd5)
  119.  else
  120.  if dd_value == 5 then
  121.   dd_value = dd_value +1
  122.   stopAnimation(dd5)
  123.   startAnimation(dd6)
  124.  else
  125.  if dd_value == 6 then
  126.   dd_value = dd_value +1
  127.   stopAnimation(dd6)
  128.   startAnimation(dd7)
  129.  else
  130.  if dd_value == 7 then
  131.   dd_value = dd_value +1
  132.   stopAnimation(dd7)
  133.   startAnimation(dd8)
  134.  else
  135.  if dd_value == 8 then
  136.   dd_value = dd_value +1
  137.   stopAnimation(dd8)
  138.   startAnimation(dd9)
  139.  else
  140.  if dd_value == 9 then
  141.   dd_value = 0
  142.   stopAnimation(dd9)
  143.   startAnimation(dd0)
  144.   check_td_score()
  145.  end end end end end end end end end end
  146. end
  147.  
  148. -- * local variables for triple digit score* --
  149. local td_value = 0
  150. local td = getObject('Scenes[Scene_001].SceneObjects[triple_digit_score]')
  151. local td0 = td:getObject('.ObjectAnimations[triple_0]')
  152. local td1 = td:getObject('.ObjectAnimations[triple_1]')
  153.  
  154. -- * triple digit score * --
  155. function check_td_score()
  156.  if td_value == 0 then
  157.   td_value = td_value +1
  158.   stopAnimation(td0)
  159.   startAnimation(td1)
  160.  end
  161. end
  162.  
  163. -- * reset score * --
  164. function reset_score()
  165.  if sd_value > 0 or dd_value > 0 or td_value > 0 then
  166.   sd_value = 0
  167.   dd_value = 0
  168.   td_value = 0
  169.   -- * --
  170.   stopAnimation(td1)
  171.   startAnimation(sd0)
  172.   startAnimation(dd0)
  173.   startAnimation(td0)
  174.   -- * --
  175.   for i = 1, 9 do
  176.    local single = sd:getObject('.ObjectAnimations[single_' .. i .. ']')
  177.    local double = dd:getObject('.ObjectAnimations[double_' .. i .. ']')
  178.    stopAnimation(single)
  179.    stopAnimation(double)
  180.   end
  181.    print('score has been reset!')
  182.  end
  183. end
Advertisement
Add Comment
Please, Sign In to add comment