Game Development Community

How do I get the Byte value of a Char or string etc?

by Chris Dillman · in Torque Game Builder · 09/13/2005 (2:06 pm) · 3 replies

How do I get the Byte value of a Char or string etc?

Im trying to make a class on in script to display a bitmapped font on screen.

I can get each char in a string
and then I want to use the byte value of that char as the index of the frame of
a sprite to display.

Like you could in C/C++ etc.

Im not sure this can be done in T2D.

Anyideas are welcome...

Could I make an array? or dictionary object of some kind that worked like a hash table
and would look up the frame index value of my char?

#1
09/13/2005 (4:01 pm)
Quote:Im trying to make a class on in script to display a bitmapped font on screen.

Can't you just use the font drawing routines in T2D for this? There's GUI widgets that can handle this, and T2D either has a text scene object or someone has made one that you can use just as well.
#2
09/13/2005 (4:30 pm)
Back in my start with T2D, I did a very similiar thing, except I actually added a few console function to return a byte from a string.

John Vanderbeck posted a solution that requires zero engine mods:

%val = strpos($testStr, %chr);

where

$testStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

This is more elegant than my engine-hacking solution. :)
#3
09/13/2005 (5:15 pm)
Thanks guys
thats is a neat little solotion.

Im really trying to stay away from patching the C++ side of things
as it will make it much harder to update to new versions of the code base when they come out.

At this point I already have like 8 patches needed for teh OX-X version alone to make it work correctly.