Display value of an math_counter Created 16 years ago2008-03-16 18:12:02 UTC by The Mad Carrot The Mad Carrot

Created 16 years ago2008-03-16 18:12:02 UTC by The Mad Carrot The Mad Carrot

Posted 16 years ago2008-03-16 18:12:39 UTC Post #247726
Ok.

I have a math_counter, initial value 0.
I have 3 func_buttons. Each button adds a value of 100 to the initial value of the math_counter.
So when all the buttons are pressed, the value should be 300.

Now i want to display this value to the player. I was thinking about a game_text. But i can't figure out a way to make game_text display the value of the math_counter to the player, since you're only allowed to type in text in the Text to display property field.

So is there way to do this?

Valve should inplement something like this:

Lets say mcounter_score is the name of the math_counter entity.
Then, in the Text to display property of the game_text, you type in:
mcounter_score(value)
So that the game_text displays the value of the entity named mcounter_score.

But nooo...
Posted 16 years ago2008-03-16 18:20:14 UTC Post #247727
well there should only be 4 cases of values (0,100,200,300) so using game_texts manually shouldn't be hard. but counters are more used for logic than actual user interaction.
Penguinboy PenguinboyHaha, I died again!
Posted 16 years ago2008-03-16 19:00:20 UTC Post #247728
Ehh no, thats not gonna work, since i need those numbers to add up.
Think of it like a score system in somekind of platform game (Duke Nukem 2/3d, Commander Keen, Alien Carnage and the like)

Adding up numbers with a math_counter works fine. I just need actually show the value of the math_counter to the player.
Posted 16 years ago2008-03-16 19:34:08 UTC Post #247731
oh, i thought that they were once only. i don't think you can do it without coding.
Penguinboy PenguinboyHaha, I died again!
Posted 16 years ago2008-03-17 17:50:55 UTC Post #247755
I made a functioning blackjack table prefab once where I gave a value to the suit, a value to the, uh, value (A, 2, 3.. J, Q, K) and then when the player was assigned cards, used a combination of logic_case and game_text to determine and display the output. The resulting entity setup was pretty impressive to look at, because it was laid out exactly like the flowchart I used to design the logic.
Unrelated? Not quite! My point is, know what entities you have at your disposal, and then draw a flow chart of how the logic will flow, then convert each point of that to a Source entity on your little drawing. It makes complicated ent setups easy!
Basically,
1. Have a logic_case, with case 1 as 0, case 2 as 100, case 3 as 200, and case 4 as 300.
2. Have 4 game_text's, named text0, text100, text200 and text300, with message text like 'Counter: 0' etc. or something
3. For the outputs of the logic_case
a) OnCase1, text0.display
b) OnCase2, text100.display
c) OnCase3, text200.display
d) OnCase4, text300.display
4. The output of your math_counter should then output it's value to the InValue of the logic_case.
Hope that helps!
HOWEVER:
I would suggest, rather than using the UI to display the value, create 4 textures with the values written on, have a counter on the wall, create 4 func_illusionary brush entities textured with the seperate textures all in one place, as part of a counter on the wall. Then set the alpha of the appropriate one to full and the other to 0 via the OnCase1 outputs of the logic case. Would look much more impressive :)
Posted 16 years ago2008-03-17 19:01:31 UTC Post #247756
So a logic_case works like the Select Case statement in the VB .NET programming language? In that case, you're idea might work. Im going to try it out asap. Ill let you know the results. :)
Posted 16 years ago2008-03-19 08:11:00 UTC Post #247804
I don't code in VB.NET, so I can't really agree or disagree with that =p
What I can tell you is, done correctly, it will work. Fact.

]

Posted 16 years ago2008-03-20 11:01:33 UTC Post #247829
Chrispy, your idea works great! Thanks! Ill give you credits (Its for the current compo). :)
Posted 16 years ago2008-03-22 23:30:03 UTC Post #247891
Ahhh... God love Half-Life.
There's like 400 ways to do ANYTHING
Tetsu0 Tetsu0Positive Chaos
Posted 16 years ago2008-03-23 07:36:56 UTC Post #247911
FYI, this is Source. :)
You must be logged in to post a response.