Notifications
Clear all

[Closed] Animated Text

Hi, sorry, already advising I’m newb to MaxScript.
I read in the MAXScript Reference about Animated Text, but I still didn’t understand the controller script concept.
Is there anywhere I could learn more about this?

I used the example linking the box height to the text value.
But what I need is to restrict that value to a one decimal number (ex: 35,2) and add a 0 (zero) at the end: (ex: 35,20).

 b=box name:"ControlBox" wirecolor:blue
t=text name:"ControlledText" wirecolor:red
t.baseobject.renderable=true
t.kerning.controller=float_script()
scrpt="dependsOn $'"+b.name+"';$'"+t.name+"'.text=$'"+b.name+"'.height as string
0" 
t.kerning.controller.script=scrpt 
animate on at time 100 b.height*=2 

Thanks in advance.

2 Replies

Which version of Max are you using?
Max 9 has formatting controls where you can specify how your numbers will appear when printed.
In earlier versions, you would need to manipulate the value yourself.

For example, if

a = 12.345678
12.3457

then to get what you want you would multiply by 10 to move one decimal point to the right, add 0.5 and round down to round correctly up if greater than .5 and down if less than .5, then divide by 10 to reintroduce the decimal point with one number after it, convert to string and add the zero as string to the final result.

((floor ((a*10)+0.5))/10.0) as string + “0”
“12.30”

In your scripted controller, you can do the same:


b=box name:"ControlBox" wirecolor:blue
t=text name:"ControlledText" wirecolor:red
t.baseobject.renderable=true
t.kerning.controller=float_script()
scrpt="dependsOn $'"+b.name+"';$'"+t.name+"'.text= ((floor (($'"+b.name+"'.height*10)+0.5))/10.0) as string + \"0\"
0" 
t.kerning.controller.script=scrpt 
animate on at time 100 b.height*=2 


Thanks a lot…

Now, another question… Can I use functions in this script? If so, how?
Because I want to change the “.” to a “,” or to a ” ” (space). Is there any way to do this without using functions?

Thanks