Need Chr() function in in Enhanced object scripts
Hi Racerender Dev team
Is it at all possible to have a Chr() function available to convert Ascii code to text.
I understand your challenges around enabling the ability to pass text rather than numbers in the data file. Currently I am successfully displaying some code words on screen, by passing a number in the data file, and then using an if/else statement converting that number to the appropriate text string. However that will only work with a limited subset of possible text strings. For this bit I only have about 20 possible strings so that makes a 20 deep if/else statement. This obviously comes with some overhead in processing time. To improve this I have set a persistent variable, and only process the if/else when the string needs to change from the previous frame.
But for the next bit of my project I desperately need the ability to display much longer strings, as I require road names to be displayed on screen. If I was able to build up a very long number where every set of 2 digits is an ascii code, I could then decode this in the Advanced function script, by breaking the number into 2 character chunks, and use the Chr() function to build up a string.
Admittedly breaking a large number into chunks is currently possible but a bit cumbersome, so any function you could provide to ease that would also be helpful. At the moment I have achieved it with something like below to convert a 4 digit number with 2 decimals. (1156.11 or 2055.12))
nType = floor(DataValue/1000) #extract the thousands number
nFeature = trunc(DataValue - nType*1000) #extract the 100s
nExtention = trunc((DataValue-nFeature-(nType*1000))*10) #extract the 1st decimal number
nExtention1 = (DataValue-nFeature-(nType*1000))*100 - (nExtention * 10) #extract the second decimal number
Then with a if/else I build that back into a string.
If nType is 1 then "BR", elseif nType is 2, "Tun"
add the nFeature as a 3 char string,
If nExtention is 1 then "A", elseif nExtention is 2, "B"
If nExtention1 is 1 then "A", elseif nExtention1 is 2, "B"
that allows me to display a variety of "Tun156AA" or "Br055AB" etc
Any help you could offer would be much appreciated.