playMaker

Author Topic: Convert Seconds to string[SOLVED]  (Read 75176 times)

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Re: Convert Seconds to string[SOLVED]
« Reply #30 on: October 25, 2014, 03:10:31 PM »
Hello,

i cannot find this action on ecosystem..
but well, trying to use the one linked on others post,
i have a problem to set the format of the time, see the screenshot....

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Convert Seconds to string[SOLVED]
« Reply #31 on: October 25, 2014, 06:24:52 PM »
It's on there - search 'time'

also your formating looks correct .. not sure what is going on there :S

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Re: Convert Seconds to string[SOLVED]
« Reply #32 on: October 27, 2014, 03:22:22 AM »
it works correctly if i use format 00:00:00

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Convert Seconds to string[SOLVED]
« Reply #33 on: November 27, 2014, 01:35:14 AM »
Hi,

 Yeah, I can confirm it's on the ecosystem, search for "convert seconds".

Bye,

 Jean

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Convert Seconds to string[SOLVED]
« Reply #34 on: December 02, 2014, 08:15:24 AM »
Hey Jean,

How would you reverse this action so it would count down from a value ie 10 mins/ 600 secs?

Try This

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Convert Seconds to string[SOLVED]
« Reply #35 on: November 19, 2015, 10:04:53 AM »
Hi,

 Following a post: http://hutonggames.com/playmakerforum/index.php?topic=1700.msg7433#msg7433

please find a convenient action that will convert seconds into a formated string to display, days, hours, minutes, seconds, milliseconds, total days, total hours, total minutes, total seconds, total milliseconds.

 It's very easy to use. For example, store the time since level load in a float using the action "get time info" and then inject that float in this action and specify a string variable to output AND the format.

 example:

{1:D2}h:{2:D2}m:{3:D2}s:{4:D3}ms
if the float is 10, it will show: 00h:00m:10s:000ms

{1:D1}:{2:D2}:{3:D2}
if the float is 10, it will show 0:00:10

[EDIT]

I have added a tenth variable that will simply output the milliseconds with two digits, as the current c# formatter do not really allow for a simple way out. the default example is provided with it. Simply inject the "Time since level load" from the action "Get Time info" to see it in action.


careful with the total X values, as they are doubles, so if you want to display the total number of seconds format it like so: {8:F0}

http://stackoverflow.com/questions/463642/c-what-is-the-best-way-to-convert-seconds-into-hourminutessecondsmilliseco

http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx




If you have any questions, don't hesitate

Bye,

 Jean


Hi!
Why doesn't this second to string allow me to count the miliseconds (MS) like 101,102,103,104, etc. or 10,11,12,13,14,15, etc.? It's counting only: 100,200,300,400,500, etc.

Is this not possible? Should be. I have seen it in other games! :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Convert Seconds to string[SOLVED]
« Reply #36 on: November 23, 2015, 01:18:30 AM »
Hi,

 What is the exact string format are you using?

Bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Convert Seconds to string[SOLVED]
« Reply #37 on: November 26, 2015, 06:21:35 AM »
Hi!
Thanks for the answer! :)

I use this format: {2:D2}:{3:D2}:{10}
And it counts like this: 00m:00s:00ms
I want ms to be like: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
Not 00, 10, 20, 30, 40, 50, 60, 70, 80, 90
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Convert Seconds to string[SOLVED]
« Reply #38 on: December 01, 2015, 06:19:09 AM »
Hi,

simply use "{1:D1}h:{2:D1}m:{3:D1}s:{4:D3}ms"

and you'll get:



your format is wrong for the ms, {10} isn't right.

 Bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Convert Seconds to string[SOLVED]
« Reply #39 on: December 04, 2015, 08:18:28 AM »
Ok!
But the format is still not what I want! I want this:
00:00:0 not 00:00:000

I deleted hour since I'm not going to have that.

I tried to set it up like this: {2:D1}:{3:D1}:{4:D1}, since I don't want to have the two zero at the end, but it's still counting like this: 00:00:100, 00:00:200, 00:00:300, etc.

Is it not possible? Or is it possible to update the Action so it will be possible?

Another thing maybe I do wrong is the Wait Action! The first state I have Wait 0.1.
The next state I have:
-Float Add 0.1
-Convert Seconds To String
-U Gui Set Text

I see in the screenshot that it is 058 ms. I don't get that
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Convert Seconds to string[SOLVED]
« Reply #40 on: December 05, 2015, 07:03:51 AM »
Hi,

 I see... indeed if you wait a 0.1 seconds you'll only get times with this accuracy :) this is logical

 The action is using the standard c# .net format, so there is no other way using this method.

when you have such issues, starts with a clean scene, one gameobject, one fsm, one state, one action, study how it works and then you can apply it back to your real environment. Typically, you'll find that this action has it's ms properly working, but indeed within your system, since you wait 0.1 everytime you parse, you won't get more precise by definition of your logic.

 Bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Convert Seconds to string[SOLVED]
« Reply #41 on: December 07, 2015, 01:09:02 PM »
Hi!

I also tried to use Float Interpolate on the ms, so the ms will use 1 second to reach 1000 or 100 or 10 and then I add 1 to the second. I got it to work in this way. The only problem I got was not the timer itself, but when I use Easy Save to save the time. It was a problem when I got a new best time, since I use Convert Seconds To String on minutes and seconds and ms is separated. I use Float Compare to check if the current time is higher than the best time. And here is the problem since min. and sec. are in one variable and ms is in another variable.

Hope you understand me! It was a little bit difficult to explain. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Convert Seconds to string[SOLVED]
« Reply #42 on: December 12, 2015, 07:15:26 PM »
Jean:
I got it to work! I didn't use "Convert Seconds To String" I use "Float Interpolate", and seconds and milliseconds separated! I had to do everything manually! I can show a video of how it works! :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Convert Seconds to string[SOLVED]
« Reply #43 on: December 14, 2015, 03:31:15 AM »
I created a new topic with a link of the video of the Game Time!

http://hutonggames.com/playmakerforum/index.php?topic=11833.0

Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Convert Seconds to string[SOLVED]
« Reply #44 on: December 14, 2015, 05:59:35 AM »
Hi,

 Nice, I am glad you got it working!

 I think I understand now what you are looking for that the string format doens't provide. I'll see if I can get an update on the action to feature this.

 Bye,

 Jean