How do I convert game time (seconds) to int64 for Game Centre?

Northfield82

• Posts: 649
Hello,

I want to convert how long it took someone to complete my game (currently in seconds) into a 64 bit signed integer so I can have it submitted to Game Centre to record best times.

How do I go about doing this in Stencyl, anyone know the math?

Muchos

Rich

« Last Edit: August 10, 2016, 08:13:39 am by Northfield82 »

Northfield82

• Posts: 649
Any ideas on this one?

Thanks

colburt187

• Posts: 2416
Yeah i think i have this on an old game, Ill get it too you tonight if no one else does before.

Northfield82

• Posts: 649
Brillant, thanks mate. Appreciated

colburt187

• Posts: 2416
You should also look up the Time Count Behavior on the stencyl forge, I used it in the past, was a great help.

Northfield82

• Posts: 649
Is that related to converting to to a 64 bit integer?  I have the actual timer working great, it's just the Game Centre requirements for this to be converted into a 64 bit integer that has stumped me.

So if someone takes 5,000 seconds to complete the game Game Centre then converts that to hh:mm:ss through this 64 bit signed integer....

Cheers

colburt187

• Posts: 2416
Yeah I think time count splits it up into MM:SS for you, ill look at how i did it and see if it will work for your timer.

Hectate

• Posts: 4643
You'll probably want to use this just to be certain:
A cross-platform signed 64-bit integer. Int64 instances can be created from two 32-bit words using Int64.make().
 :: Patience is a Virtue,But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Northfield82

• Posts: 649
You'll probably want to use this just to be certain:
A cross-platform signed 64-bit integer. Int64 instances can be created from two 32-bit words using Int64.make().
Thanks Hectate - I take it I would have to use that with one of the empty Stencyl Code blocks?

I'm pretty inexperienced in actual coding so I don't know how to use Int64.make() with the number variable that holds my recorded game time

colburt187

• Posts: 2416
This is what i was doing, But because i was using the time count behaviour my values would be different from yours, so Hectate's answer is probably the way to go.

Northfield82

• Posts: 649
So I would also round my time and multiply by 100?  Why the multiply by 100?

Hectate

• Posts: 4643
I presume colburt was having the player's score be Time x 100 (e.g. 30 seconds would be 3,000 points); the rounding is just to get rid of excess decimal value (e.g. 30.125 seconds == 3012.5 points).

Yeah you'd need code blocks but since I've not used the Int64 type myself I'm not sure the exact syntax needed. Interestingly though, if Colbert's example is working, perhaps you can just submit the straight number value and it'll work?
 :: Patience is a Virtue,But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Northfield82

• Posts: 649
So I'm just throwing mud at a wall here and seeing what sticks, but is this anywhere near?
(attached)

« Last Edit: August 12, 2016, 10:11:52 am by Northfield82 »

colburt187

• Posts: 2416
If I'm being honest I don't know how it works, Time count magic, but it submits the time in Hours, mins, seconds. See the attached screenshot from game centre.

Northfield82

• Posts: 649
So is the screenshot above directly related to screenshot of the block you posted further up?