[Prefab] Counter

[PREFAB] Counter 2015-10-12

wiseguy149

Emperor of Entities and Amateur of Aesthetics
May 12, 2009
103
220
[Prefab] Counter - A clean-looking, versatile, and efficient counter prefab including custom materials and models.

:engieyay: [PREFAB] Wiseguy's Custom Counter, V1.0 :engieyay:
While working on the next version of walkway, I ended up creating a much more efficient, pretty, and customizable counter that looks a little something like this:
TbGGCHS.png


It takes advantage of animated textures and material_modify_control entities to change the digits that are displayed. This is a more entity-efficient setup than the rotating brushes, and also has the advantage of being easily rescalable without any additional difficulties.
It's configured with relays that take in inputs to add 1 or subtract 1, but if you want to manually set the counter to something specific, you can change any digit to any number at any time, which wasn't possible before.



:psyduck: How it Works :psyduck:

An in-depth tutorial on all of the techniques I used is coming soon.



:intelgray: Download Contents :intelgray:

Here's what you get when you download this zip:
  • A texture for digits 0-9.
  • Blank sign models that come in two sizes and two team colors, to serve as a nice backing for the digits.
  • A sign model with multiple skins for everything you might want to count, such as time, kills, deaths, points, and even hats.
  • A prefab of the two-digit and eight-digit versions of the counter.
  • A map (bsp and vmf) demonstrating a couple of basic uses for the counter.
  • A readme file that most of you will never read.


:cap: FAQ :cap:
Can I use this in my map?
Sure, feel free to use anything from the download in your maps, but please credit me.

How do I use this counter?
Make sure you have texture lock :texlock: on, and place the prefab in your map. Then setup whatever entities you want to trigger the relays to add or subtract. Or, if you want to manually set it to a specific number, you can call SetValue on the counter for each digit.

Seriously, how the hell does this work?

The short answer is material_modify_control entities used in conjunction with animated textures to manually cycle through their frames. The long answer is I'm working on a more detailed tutorial that will explain how I used these entities to create this counter and everything else you can do with them as well.

Your prefabs only have two and eight-digit counters. What if I want a different number?
If you want less than eight digits, just chop off the ones you don't need. If you want more, just duplicate 4 entities for each digit as much as you need.

What if I want to make the numbers really big?
Just enable texture lock scale :texlockscale: and resize the brushes that contain the digits until they're as big as you want them. Or you can do it manually.

What if I want to make the numbers a different color?
Open digit.vmt (in the custom materials folder) and change the $color variable to whatever you want it to be.

What if I want to make the numbers a different font?
If you know how to make an animated texture, just make one with the images for 0-9 as frames 0-9. If you don't know how to do this, ask me and I can probably help you out.

Help, whenever I add/subtract from the counter, it changes all the digits to the same thing instead of just updating one digit.
Each prefab contains a logic_auto with an output at the start of the map to forcefully sets every counter to zero and update the digit textures. Make sure you're not missing this output. Even though both the counters and the digits already default to zero, you will encounter this bug if you don't send them an initial input before you do anything else.

I want a sign with a different word on it so I can count something else.
If you know how to reskin an existing model, go for it. Otherwise, just ask me and I can probably help you out and make a new skin for you.

I have a question and it's not in this FAQ.
Post it here in the discussion thread or add me on steam and I'll get back to you as soon as I can.
 
Last edited:

wiseguy149

Emperor of Entities and Amateur of Aesthetics
May 12, 2009
103
220
Awesome! Would this bychance have any adverse affect on framerate? Thinking about using this in my trade server map (somehow, haven't figured out how/where yet) but I'm a bit worried about all the entities and causing framerate drops.
Nothing that I've noticed so far. Excessive amounts of entities always has the potential to affect performance, but it's been my goal with this setup to keep it as relatively lightweight as I could. It shouldn't be significant enough to reduce your framerate, but if you do find any issues with it, please let me know.
 

ProfHappycat

Server Staff
Aug 2, 2015
153
354
looking very nice! I can see the "kills" one being used in player destruction maps
also, learning how to set a custom one up would be handy, can't wait for the tutorial!
 

PossessedInkieShark

L3: Member
Mar 27, 2015
113
32
For some reason, when I tried to make 2 counters, the right digit of the red counter and the left digit of the blue counter copy each others texture alterations, same with the left digit on the red counter and the right digit of the blue one.It just seems to be a texture issue, as the triggers seem sound. I also included a auto to set the textures when the map spawns.
Any advice?
Pic:
2016-02-19_00002.jpg
Vmf included so you can look at the triggers
 

Attachments

  • test_ac.vmf
    74.9 KB · Views: 276

wiseguy149

Emperor of Entities and Amateur of Aesthetics
May 12, 2009
103
220
For some reason, when I tried to make 2 counters, the right digit of the red counter and the left digit of the blue counter copy each others texture alterations, same with the left digit on the red counter and the right digit of the blue one.It just seems to be a texture issue, as the triggers seem sound. I also included a auto to set the textures when the map spawns.


You're missing the 0 case from the third digit of each counter.

To explain in more detail for everyone, I discovered this bug while developing these. Basically, the bug requires the same material on different entities to be controlled by material_modify_controls. If one of the controllers makes and adjustment to the texture, but the other one hasn't received any input yet since the map loaded, the other one will copy the texture adjustments even though it hasn't been told to.
The fix for this was simple, having the logic_auto set every frame to 0 at the start of the map, so that every material had received inputs and would behave properly.
However, you modified the third digit of each counter to only count to 3. This isn't innately a problem, but you neglected to allow for 0, which is the case that the digit starts at. Since no case covers 0, the material_modify_control for both third digits never receive their first input at the start of the map, and the bug occurs.

Here's a tip on how I solved this: When trying to debug entities in the future, the developer console command is invaluable. It outputs all of the entity I/O to the console. I used this to debug your map and noticed that the controllers for each third digit never got their set frame to 0 at the start of the map inputs that the other controllers received.