# UUID

# Overview

UUID stands for universally unique identifier. Spyric UUID is similar to the standard UUID, but the identifiers that are generated by this plugin are of varying lengths and they are intended to be used to identify specific installations of a particular Solar2D developer's apps.

Spyric UUID is more unique than most other UUID implementations for Lua and it is also simpler and faster to run.

# Gotchas

  • Spyric UUID consists of three parts: 1) a single letter platform identifier, 2) current epoch (unix) time in milliseconds (if sockets are supported, otherwise rounded to seconds), and 3) time to execution.
  • Time to execution is how many milliseconds have passed between when this plugin was first required and when the UUID is generated. This means that you should require the UUID plugin at the very top of your main.lua and only run the UUID.new() function after done other operations, like having required other plugins, libraries, modules, etc. first. This will give your UUID more uniqueness as it is unlikely that two devices take the same time to execute your code to the point where the UUID gets created. When paired with the current time, this makes UUID collisions practically impossible.
  • The UUID is GDPR compliant and it stores no personally identifiable information.
  • To learn more about UUID, please refer to this Wikipedia article on UUID.

# Setting up

Spyric UUID is a fully open-sourced plugin. In order to set it up, all you need to do is download it from GitHub, then place it in your project's root folder and require it.

local UUID = require( "UUID" )

# Functions & syntax

new: create a new UUID.

UUID.new()

# Examples

Create a UUID for the installation.

-- Require the UUID plugin at the very start of your main.lua.
local UUID = require( "UUID" )

-- Require other plugins, modules and libraries, e.g. AdMob, Unity,
-- Appodeal, Composer, IAPs, etc. in order to create more uniqueness.

-- Some time later, create the UUID.
local id = UUID.new()
print( id ) -- output: a-1624453244-2131-4