Yet another "UVfontless" counter. (Python/.blend)

It’s nothing groundbreaking, there were a few similar demos before on the subject, and also p00f made one not so long ago (if anyone remembers).

However I found yet another way to go about it, and it actually turns out to be relatively simple, and even pretty in it’s own way.

So, for anyone interested:

#Yet another UVfontless counter -Social

cont = GameLogic.getCurrentController()
own = cont.getOwner()

hun_act = cont.getActuator("hun_act")
ten_act = cont.getActuator("ten_act")
one_act = cont.getActuator("one_act")

score = int(own.prop)

if score == 999:
    own.prop = 0

s1 = 0
s10 = 0
s100 = 0

if score < 10:
    s1, = [int(char) for char in str(score)]
    if score < 100:
        s10, s1 = [int(char) for char in str(score)]
        s100, s10, s1 = [int(char) for char in str(score)]

GameLogic.addActiveActuator(hun_act, 1)
GameLogic.addActiveActuator(ten_act, 1)
GameLogic.addActiveActuator(one_act, 1)

The .blend is here:


How lazy you are…no I’m joking :slight_smile:
Well, it’ll be nice if you could comment your scripts?!
Me and most people here don’t want to learn Python, but
seeing the comments everytime, at least the basics will “enter”,
and comments help a lot if we want to reuse the script.
And…maybe a “backward” version, please?!
Anyway, its a nice one.

Looks a little more resource heavy, but interesting to know. Thanks!

Well, that’s a problem you, and “most people” will have to deal with sooner or later. :slight_smile:

That said, this simple little script requires no comments, trust me.

I simply use 3 variables to “break down” score into it’s ones, tens and hundreds respectivelly, with the [int(char) for char in str(score)] line, and then according to any given number I change the mesh replace object for the given actuators.

The “secret souce” in all of this (if you can call it that) is the fact that all the replace meshes are named 0-9, so instead of making control statements for determining which mesh should be called for which number, I just use the number itself by turning it into a string str(s1/10/100), so I can just plug it direct into setMesh()

And…maybe a “backward” version, please?!
Could you elaborate on that please?

If your talking about all the unnecessary polygons that make up the numbers, that’s just because I quickly used blenders native text, turned it into a curve [ALT] + [C], and then to mesh [ALT] + [C] (again), so it’s somewhat more highpoly than it needs to be.

That’s easy to fix though, because you can use whatever you want for number objects. I just scrapped this up for the demo.

Euhhh…from 10 to 0 for example?!
Euhhh…I should said “couldn’t” learn python :slight_smile:


Sure, just set the Timer to a negative triple (or lower) digit number (like -300 for example), and make the following changes to the code:

score = int(own.prop * (-1))

if score == 0:
    own.prop = (-300) # The -300 being the number you choose to count down from.

Euhhh…I should said “couldn’t” learn python :slight_smile:
Did you go through my tutorial? It’s should get you started with the basics.

It’s not as hard as it may seem, and it brings about many benefits (even though this little piece of mental masturbation doesn’t show it, it does, trust me).

PS: I get the feeling that english is your second language.

At least, the fourth! :slight_smile:
Thanks for the “backward” script.

I love the look of mechanical Timers and score keepers, really adds a lot to the game ambiance I think.
The best thing over a raster font I think is the scaeling ability. You keep nice smooth edges with a mesh, where with a Raster texture font you get Jaggie edges when you scale it up.
Great for playing on your 100 inch HDTV setup (lol wonder if they really make them that big)

Thanks again for the script Social :slight_smile: