UpTime Native Extention

UpTime

This Defold Native Extension allows receiving a system uptime.
This timer resets when user restarts their device!

Possible use cases:

  • If you want to use a timer for restore lives (or something else) in your game without server but want to have better protection against cheaters who just change system time.
  • Seed for math.randomseed() (thanks @dragosha for that use case idea)

Platforms

  • iOS
  • MacOS
  • Android
  • Windows

Setup

You can use the UpTime extension in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:

https://github.com/AGulev/uptime/archive/master.zip

Or point to the ZIP file of a specific release.

API

uptime.get()

Returns system uptime in seconds.

local function update_uptime(self)
  if uptime then
    local uptime = uptime.get()
    print(uptime) -- 809031
  end
end

Issues and suggestions

If you have any issues, questions or suggestions please create an issue or contact me: me@agulev.com


UPD:
Added windows support

16 Likes

Brilliant!

2 Likes