Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: MaDDoX on May 21, 2011, 07:30:22 AM

Title: Convert Int/Float to String - now with Format Option
Post by: MaDDoX on May 21, 2011, 07:30:22 AM
In many circumstances it helps a lot to get a string formatted in a specific way straight during the conversion stage from an int of float, instead of going through a routine to format the string after the fact. C# has some nice built-in format strings just for that, which weren't exposed in Playmaker - so far :)

A couple good examples of use:

-Leading zeroes on an int-converted variable. Suppose you have values like 20, 140 and want to see them shown as 0020, 0140, etc. To do that you'd use Format = "0000" or "D4"

- Format in percentage notation a float number, for instance, convert 0.2 to 20% in a statistics display. For that you'd use format = "P2".

For more information on the available options, read here:
http://www.blackwasp.co.uk/CSharpNumericToString.aspx

To install simply overwrite the original actions in Assets/Playmaker/Actions. If it's an existing project don't worry, these actions are compatible with any existing data, if the 'format' field is set to null it performs the original, no-format behavior. Hope you find it of use, enjoy!
Title: Re: Convert Int/Float to String - now with Format Option
Post by: edufurla on October 07, 2013, 04:06:40 PM
Nice addition.
Thanks for sharing.
Title: Re: Convert Int/Float to String - now with Format Option
Post by: wheretheidivides on January 23, 2015, 02:11:03 PM
To get 98% (no decimals) then it's:
#%