Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- * notes * --
- -- 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!
- -- 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 ...
- -- 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 ...
- -- you get the general idea; I think?
- -- * local variables for single digit score* --
- local sd_value = 0
- local sd = getObject('Scenes[Scene_001].SceneObjects[single_digit_score]')
- local sd0 = sd:getObject('.ObjectAnimations[single_0]')
- local sd1 = sd:getObject('.ObjectAnimations[single_1]')
- local sd2 = sd:getObject('.ObjectAnimations[single_2]')
- local sd3 = sd:getObject('.ObjectAnimations[single_3]')
- local sd4 = sd:getObject('.ObjectAnimations[single_4]')
- local sd5 = sd:getObject('.ObjectAnimations[single_5]')
- local sd6 = sd:getObject('.ObjectAnimations[single_6]')
- local sd7 = sd:getObject('.ObjectAnimations[single_7]')
- local sd8 = sd:getObject('.ObjectAnimations[single_8]')
- local sd9 = sd:getObject('.ObjectAnimations[single_9]')
- -- * single digit score * --
- function check_sd_score()
- if sd_value == 0 then
- sd_value = sd_value +1
- stopAnimation(sd0)
- startAnimation(sd1)
- else
- if sd_value == 1 then
- sd_value = sd_value +1
- stopAnimation(sd1)
- startAnimation(sd2)
- else
- if sd_value == 2 then
- sd_value = sd_value +1
- stopAnimation(sd2)
- startAnimation(sd3)
- else
- if sd_value == 3 then
- sd_value = sd_value +1
- stopAnimation(sd3)
- startAnimation(sd4)
- else
- if sd_value == 4 then
- sd_value = sd_value +1
- stopAnimation(sd4)
- startAnimation(sd5)
- else
- if sd_value == 5 then
- sd_value = sd_value +1
- stopAnimation(sd5)
- startAnimation(sd6)
- else
- if sd_value == 6 then
- sd_value = sd_value +1
- stopAnimation(sd6)
- startAnimation(sd7)
- else
- if sd_value == 7 then
- sd_value = sd_value +1
- stopAnimation(sd7)
- startAnimation(sd8)
- else
- if sd_value == 8 then
- sd_value = sd_value +1
- stopAnimation(sd8)
- startAnimation(sd9)
- else
- if sd_value == 9 then
- sd_value = 0
- stopAnimation(sd9)
- startAnimation(sd0)
- check_dd_score()
- end end end end end end end end end end
- end
- -- * local variables for double digit score* --
- local dd_value = 0
- local dd = getObject('Scenes[Scene_001].SceneObjects[double_digit_score]')
- local dd0 = dd:getObject('.ObjectAnimations[double_0]')
- local dd1 = dd:getObject('.ObjectAnimations[double_1]')
- local dd2 = dd:getObject('.ObjectAnimations[double_2]')
- local dd3 = dd:getObject('.ObjectAnimations[double_3]')
- local dd4 = dd:getObject('.ObjectAnimations[double_4]')
- local dd5 = dd:getObject('.ObjectAnimations[double_5]')
- local dd6 = dd:getObject('.ObjectAnimations[double_6]')
- local dd7 = dd:getObject('.ObjectAnimations[double_7]')
- local dd8 = dd:getObject('.ObjectAnimations[double_8]')
- local dd9 = dd:getObject('.ObjectAnimations[double_9]')
- -- * double digit score * --
- function check_dd_score()
- if dd_value == 0 then
- dd_value = dd_value +1
- stopAnimation(dd0)
- startAnimation(dd1)
- else
- if dd_value == 1 then
- dd_value = dd_value +1
- stopAnimation(dd1)
- startAnimation(dd2)
- else
- if dd_value == 2 then
- dd_value = dd_value +1
- stopAnimation(dd2)
- startAnimation(dd3)
- else
- if dd_value == 3 then
- dd_value = dd_value +1
- stopAnimation(dd3)
- startAnimation(dd4)
- else
- if dd_value == 4 then
- dd_value = dd_value +1
- stopAnimation(dd4)
- startAnimation(dd5)
- else
- if dd_value == 5 then
- dd_value = dd_value +1
- stopAnimation(dd5)
- startAnimation(dd6)
- else
- if dd_value == 6 then
- dd_value = dd_value +1
- stopAnimation(dd6)
- startAnimation(dd7)
- else
- if dd_value == 7 then
- dd_value = dd_value +1
- stopAnimation(dd7)
- startAnimation(dd8)
- else
- if dd_value == 8 then
- dd_value = dd_value +1
- stopAnimation(dd8)
- startAnimation(dd9)
- else
- if dd_value == 9 then
- dd_value = 0
- stopAnimation(dd9)
- startAnimation(dd0)
- check_td_score()
- end end end end end end end end end end
- end
- -- * local variables for triple digit score* --
- local td_value = 0
- local td = getObject('Scenes[Scene_001].SceneObjects[triple_digit_score]')
- local td0 = td:getObject('.ObjectAnimations[triple_0]')
- local td1 = td:getObject('.ObjectAnimations[triple_1]')
- -- * triple digit score * --
- function check_td_score()
- if td_value == 0 then
- td_value = td_value +1
- stopAnimation(td0)
- startAnimation(td1)
- end
- end
- -- * reset score * --
- function reset_score()
- if sd_value > 0 or dd_value > 0 or td_value > 0 then
- sd_value = 0
- dd_value = 0
- td_value = 0
- -- * --
- stopAnimation(td1)
- startAnimation(sd0)
- startAnimation(dd0)
- startAnimation(td0)
- -- * --
- for i = 1, 9 do
- local single = sd:getObject('.ObjectAnimations[single_' .. i .. ']')
- local double = dd:getObject('.ObjectAnimations[double_' .. i .. ']')
- stopAnimation(single)
- stopAnimation(double)
- end
- print('score has been reset!')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment