Is it possible to format strings?

Is there a way, in Blueprint, to format strings? More specifically, I want to take the float value that is returned by “Get Game Time in Seconds”, convert it to a string, and only have the whole number and first two decimal places of the float value put into the string. Can you do that in Blueprint, or would you have to dip into C++?

Thanks!

use get substring to give a new string which includes only the first N characters based on the first string … also play with using the LEN value, or something like that, to get the length of the string

If you are wondering what is a Floor function, it’s a maths term kind of like truncate, so it would convert 1.01 into 1 (seconds)
In the image provided therefore 1.01 (time) - 1 (result of floor of time) gives .01 (decimal)

You may want to think about how do you filter 001, 010, 100 etc.
And do you need minutes (compareint if seconds = 60)

See the examples here: [Floor and ceiling functions - Wikipedia

Awesome!!!

This will find the full seconds and the decimals, and then build a string with them.

You can see my 24 hour clock by the way – it doesn’t do decimals, but you could merge it in with the above stuff if you wanted to show days, hours, minutes, seconds + decimals.

Link (p40) http://goo.gl/jEHT0u

You could take your float and use a ToText(float) node (which has formatting options) and then cast that to a string.

1 Like