- Feb 16, 2012
- 35
- 8
Anyone know how to can make a math_counter wrap around its value when it hits the min or max value? Seems simple, but for some reason it either locks up the game or it skips a number for me.
If my counter's min is 0, max is 9, initial value 0, and I have another entity telling it to "Add 1", I want the values to be like:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, ....
and if I had an entity telling my counter to "Subtract 1", then, I'd want:
0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, ...
I thought these outputs for my math_counter would work, but it locks up the game:
OnHitMax, mycounter, SetValue, 0
OnHitMin, mycounter, SetValue, 9
[I use OutValue here also, to pass the counter value to another entity]
So then I tried using SetValueNoFire instead; it kind of works, but it ends up skipping a number. For example, with subtracting 1, it would do, 0, 8, 7, 6...since OutValue wouldn't be fired.
What I have set up is a func_button that Adds 1 to my math_counter and another func_button that Subtracts 1 from my math_counter. On the wall I have an overlay that's using a animated texture with 10 frames (the VMT file has a ToggleTexture proxy, btw). I then use an env_texturetoggle to change the animated texture's current frame with SetTextureIndex when my math_counter's OutValue is fired. Essentially an animated texture, whose current frame is controlled by an "up" and "down" button.
I think that pretty much explains it. One other thing though, is there a way to see the value of a math_counter when it changes? I set "developer 3", but I only get to see the value when (in my particular case), it gets passed to SetTextureIndex. I played with "ent_messages_draw 1" and "ent_messages" as well, but they didn't seem to show the value on the screen.
If my counter's min is 0, max is 9, initial value 0, and I have another entity telling it to "Add 1", I want the values to be like:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, ....
and if I had an entity telling my counter to "Subtract 1", then, I'd want:
0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, ...
I thought these outputs for my math_counter would work, but it locks up the game:
OnHitMax, mycounter, SetValue, 0
OnHitMin, mycounter, SetValue, 9
[I use OutValue here also, to pass the counter value to another entity]
So then I tried using SetValueNoFire instead; it kind of works, but it ends up skipping a number. For example, with subtracting 1, it would do, 0, 8, 7, 6...since OutValue wouldn't be fired.
What I have set up is a func_button that Adds 1 to my math_counter and another func_button that Subtracts 1 from my math_counter. On the wall I have an overlay that's using a animated texture with 10 frames (the VMT file has a ToggleTexture proxy, btw). I then use an env_texturetoggle to change the animated texture's current frame with SetTextureIndex when my math_counter's OutValue is fired. Essentially an animated texture, whose current frame is controlled by an "up" and "down" button.
I think that pretty much explains it. One other thing though, is there a way to see the value of a math_counter when it changes? I set "developer 3", but I only get to see the value when (in my particular case), it gets passed to SetTextureIndex. I played with "ent_messages_draw 1" and "ent_messages" as well, but they didn't seem to show the value on the screen.