Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre on June 06, 2012, 03:01:28 PM
-
Hi,
Following a post: http://hutonggames.com/playmakerforum/index.php?topic=1700.msg7433#msg7433 (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://stackoverflow.com/questions/463642/c-what-is-the-best-way-to-convert-seconds-into-hourminutessecondsmilliseco)
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx (http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx)
If you have any questions, don't hesitate
Bye,
Jean
-
say one thing, say that I am amazed :D I've never seen that kind of formatting before... definitely need to read up on it ! Awesome ;D
-
Awesome work, nice flexibility in how you can display the time with : . etc :)
Thanks again Jean :)
-
How would one go about doing the reverse of this action? Convert Time formatted String into Seconds?
-
if i set the format like this: {1:D2}h:{2:D2}m:{3:D2}s:{4:D1}ms,
it does not display like this: 00h:00m:00s:0ms but like this:00h:00m:00s:000ms.
How to set ms correctly? help pls.
-
Hi,
works for me. could you give me the actual float you are using on that action?
[EDIT] my bad I checked with a real number, and I see the problem.
let say your milliseconds value is 100, D1 will still output 100, because it only asks for minimum 1, not cut it to 1.
D5 will ouput 00100
do you get it? I don't think there is a way to get out of this using this action, since it's a built in feature of c#...
the way to go about it, would be to parse the milliseconds yourself and compose the string later, so only use this action without the ms, then add the ms you want ( still using this action, but ONLY get the ms using {4:} as a formater, then cut the string and compose it using build string action.
Does that make sense?
bye,
Jean
-
Yes it does, thanks a lot! :)
-
I run into a bug here: This action kills any other string conversion -- for example if you have a separate time and score running at the same time...
-
Hi,
I am not sure I follow. Can you explain a bit more? this action in theory is complitly self contained, so it can not affect other variables then the one explicitly referenced in that action.
bye,
Jean
-
Sorry for the delay...
I had two items that wanted to show on the screen -- the time since the level start and the score points. I used Convert Int to String to show the score and Convert Seconds to String to show the time. Both work ok when only one is active, but when both are on the screen at the same time one of them no longer works...
Now, there is no problem if I run both the score and time together if I use Convert Float to String to display the time -- only Convert Seconds to String gives me the trouble.
-
Hi,
it's likely in your logic that you mix up values and tasks. Separate your logic in two fsm, that's how I would approach solcing this.
what trouble do you have with convert seconds to string? could you give me an example of your input and what you end up with?
bye,
Jean
-
As usual you are right Jean! Honestly I am not even sure what was wrong, since I no longer have it setup the same way but when I tried both time and score running together -- there was no problem... Both are running at the same time.
My guess is that the use of global variables was the cause... Is this what the bug fix was about?
-
then cut the string and compose it using build string action.
Hi,
Thanks a lot for this action!
But need format time - 00m:00s:00ms!
How can "cut the string" via PlayMaker Action?
-
Hi,
I have added this function within the action ( simply redownload it again from this thread)
{1:D2}h:{2:D2}m:{3:D2}s:{10}ms
will do the job.
Bye.
Jean
-
Hi,
Wow, amazing, great!
I am sure what who make race as I am, this will be necessary as air!
Thanks much Jean!
-
Hi,
Please see the screenshots, it's a bug or am I doing something wrong?)
If Float is 2.099 **** time is 00:02:99, next step (on paused)
Float is equal 2.103, ***, time returned 00:02:10, but should be 00:03:10
Of course this fatal error for the races ...
Quite urgently need your help!
-
Hi,
Nice catch! Quite tricky actually... Can you redownload the action and see if it works. I tested with your numbers and it works.
bye,
Jean
-
Hi,
I thought about this problem for over a week, and could not understand what was happening, all day yesterday I caught this bug :-/
I did some quick tests, so far so good and I not catched this bug again, I'll be more tested over 2-3 days, and I'll write result here. Thanks for the quick response and help!
-
Made more than 100 tests, everything works fine! Min, sec, ms, rest I don't need ;) Thank you so much, Jean!
-
Good. Thanks for the update!
bye,
Jean
-
Hi,
have spikes in debugging, the frequency I can not determine, but in ~1.5 minutes 4-5 to 20-28ms spikes
-
test in empty project spike is less
~ 4-5ms
but it's still very high ...
-
Hi,
you are fine, you are running at >100FPS! Profiling only become relevant if you go below 60FPS.
bye,
Jean
-
hmm, I have friezes in game for that reason, if I disable timer, friezes no ... you think this is normal?
-
All that more than 3-4 ms on game - is not clean code! and I have a spike in the game reaches more than 20ms - this less than 60FPS
-
Hey Jean,
How would you reverse this action so it would count down from a value ie 10 mins/ 600 secs?
-
Hi,
All that more than 3-4 ms on game - is not clean code! and I have a spike in the game reaches more than 20ms - this less than 60FPS
Yep, something is fishy here indeed. I have added this case to my todos, and I'll run some stress test to see where the problems lies. Can you come back to me next week if you haven't heard back from me?
Bye,
Jean
-
Hi,
How would you reverse this action so it would count down from a value ie 10 mins/ 600 secs?
This action only converts what you give it, so if you want to count down you simply have the float substracted instead of added and passe that to this action, unless I misunderstand what you are trying to achieve.
bye,
Jean
-
Thx, that makes perfect sense. :)
-
Hi,
You can now find this action on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) for convenience.
Bye,
Jean
-
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....
-
It's on there - search 'time'
also your formating looks correct .. not sure what is going on there :S
-
it works correctly if i use format 00:00:00
-
Hi,
Yeah, I can confirm it's on the ecosystem, search for "convert seconds".
Bye,
Jean
-
Hey Jean,
How would you reverse this action so it would count down from a value ie 10 mins/ 600 secs?
Try This (http://hutonggames.com/playmakerforum/index.php?topic=8831.0)
-
Hi,
Following a post: http://hutonggames.com/playmakerforum/index.php?topic=1700.msg7433#msg7433 (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://stackoverflow.com/questions/463642/c-what-is-the-best-way-to-convert-seconds-into-hourminutessecondsmilliseco)
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx (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! :)
-
Hi,
What is the exact string format are you using?
Bye,
Jean
-
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
-
Hi,
simply use "{1:D1}h:{2:D1}m:{3:D1}s:{4:D3}ms"
and you'll get:
(http://i.imgur.com/gvWGUT0.png)
your format is wrong for the ms, {10} isn't right.
Bye,
Jean
-
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
-
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
-
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. :)
-
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! :)
-
I created a new topic with a link of the video of the Game Time!
http://hutonggames.com/playmakerforum/index.php?topic=11833.0 (http://hutonggames.com/playmakerforum/index.php?topic=11833.0)
-
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
-
Hi, Jean!
Yes, that would be great, it would be easer, but I'm very happy and a little bit proud with my Game Time setup. :)
-
Hi,
Indeed, this is great that you got it working by yourself, this is the best way to get better and learn PlayMaker inside out.
Bye,
Jean
-
If someone is interested, I can share my game time setup! :)
-
I upload my Game Time Setup!
You can find it here! :)
http://hutonggames.com/playmakerforum/index.php?topic=11865.0 (http://hutonggames.com/playmakerforum/index.php?topic=11865.0)
-
Hi, this action is not available anymore in Ecosystem?
-
Hi,
This action is available in the default actions list
-
Sorry for necroing an old thread but I cannot get the formating to work for the life of me, could someone post an example of how this is supposed to be setup?