playMaker

Author Topic: String Format help[SOLVED]  (Read 5294 times)

Splankton

  • Sr. Member
  • ****
  • Posts: 268
String Format help[SOLVED]
« on: July 05, 2014, 01:32:35 PM »
Hi, I'm trying to format a float to just 2 digits.  the 1st digit in seconds, the second in tenths of a second.  The best I have it is with 3 digits, I just need to remove the 3rd one! Im using {3}{10}
Can someone help me out?
« Last Edit: July 12, 2014, 12:16:56 PM by Splankton »

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: String Format help
« Reply #1 on: July 05, 2014, 08:22:06 PM »
If you're just using Float to String, in the format field, "0.0" should be enough to do that.

Or if you want to have the key included, this is your friend:
http://hutonggames.com/playmakerforum/index.php?topic=1711.msg21716

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: String Format help
« Reply #2 on: July 06, 2014, 02:08:55 PM »
Ok thanks for your help.  0,0 doesn't work for some reason, it just displays "0,0"
I'm using ConvertSecondsToString, tried different formats but just cant get a 1 digit milliseconds.  Anything else to try?
Thanks again

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: String Format help
« Reply #3 on: July 06, 2014, 02:52:40 PM »
Just tested, and it works for me.

Did you try 0.0  (with a fullstop, not a comma)

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: String Format help
« Reply #4 on: July 06, 2014, 04:00:39 PM »
Yes. It just displays 0.0 instead of my time.  I'm obviously doing something wrong :-\  I think I should have mentioned my float is a timer that counts up in seconds. I want it looking like this e.g.
1.5

where 1 is seconds and 5 is tenths of a second.

Sorry for not explaining that, like I said {3}{10} gives me something like

152

1 is sec, 5 is tenths 2 is hundreths. I just want the sec and tenths.  Thanks for anymore help.  :P

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: String Format help
« Reply #5 on: July 06, 2014, 04:06:05 PM »
My advice for 0.0 was for the Float to String action, not the other one. (and it works perfectly - e.g 10.0, 9.9, 9.8 and so on.).

I'm using it on a timer that counts down from 10 to 0.  I'm using Float Subtract every frame, and Float to String every frame with 0.0 as the format)

« Last Edit: July 06, 2014, 04:07:44 PM by jess84 »

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: String Format help
« Reply #6 on: July 12, 2014, 11:57:26 AM »
Thanks again.  I have it formatted right, but I need to convert that, say 4.5 into an int of 45.  How can I remove the decimal?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4157
  • Official Playmaker Support
    • LinkedIn
Re: String Format help
« Reply #7 on: July 12, 2014, 12:04:37 PM »
Use Float Multiply to multiply by 10, then Convert Float to Int.

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: String Format help
« Reply #8 on: July 12, 2014, 12:16:35 PM »
Use Float Multiply to multiply by 10, then Convert Float to Int.

Thanks Alex  8)