Module:Guid

From Zelda Dungeon Wiki
Revision as of 23:27, June 23, 2020 by Locke (talk | contribs) (guid)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Want an adless experience? Log in or Create an account.

Documentation for this module may be created at Module:Guid/doc

function guid()
  local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
  local g = string.gsub( template, '[xy]', function ( c )
    local v = ( c == 'x' ) and math.random( 0, 0xf ) or math.random( 8, 0xb )
    return string.format( '%x', v )
  end)
  return g
end

return guid