Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
get correct elapsed time — Gideros Forum

get correct elapsed time

grotlygrotly Member
edited February 2015 in Game & application design
I need to measure the elapsed time in my game, and I tried using os.time but if I change the time in iPhone settings os.time returns the changed time as well. I would like to be able to measure the correct elapsed time even if the user changes system time and even if there is no internet connection to check the time on some server. Is there any way to do this in Gideros? Oh, and even if the user turns off the device for a few hours ;)

Comments

  • @grotly
    I think it won't be possible with any language/framework/system.. :( If you fear cheaters to change the local time on their device, the only way I can think of is an online time check as you already said. You need a clock that users can't change.

    As an alternative you could double check for consistency on your timer check:
    If the cheating user once forget to change time on his device and runs your app, if saved timestamp is "forward" in respect to os.time you could clear his savegame for "cheating reasons".. after losing one savegame, hopefully he won't bother cheating anymore.
    As a side note, I would try to understand the time zone either, most devices auto adjust time settings, and you don't want a regular paying and travelling businessman to lose his savegame :)
  • grotlygrotly Member
    edited February 2015
    Thanks for the explanation. Is there any way to use mach_absolute_time() from Gideros?
  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    I think that os.timer does something similar:
    http://docs.giderosmobile.com/reference/lua/os/timer#os.timer

    Unfortunately its arbitrary reference point depends on the OS and platform, so I would not rely on it in that way
Sign In or Register to comment.