
Share Your Code
Browse Code
- All (914)
-
(95)
-
(87)
-
(45)
-
(4)
-
(42)
-
(136)
-
(22)
-
(40)
-
(13)
-
(66)
-
(153)
-
(211)
GUID Creation Module
I needed a way to generate unique IDs for something I was working on, and since Corona doesn't have built in support for guids, and since the only other thing out there had dependencies, I wrote my own. I can't say that they adhere entirely to the spec., but they look right, and they're guaranteed to be unique, so it was good enough for me.
They looks like this:
DA3C1235-EAE1-2524-7798-63D2D8EBC487
846521A4-D962-AA9C-4EA9-566A6931D287
424EF5CA-133B-8974-9D59-2E2974166874
Usage is super simple:
On a normal something.lua page
--Require the module at the top of your page:
local guid = require "guid"
--Then call generate() to make one:
print(guid.generate());
If you're using StoryBoard
In your main.lua:
--Require StoryBoard
local storyboard = require "storyboard"
--Create a table to hold modules:
storyboard.modules = {}
--Add the GUID Module
storyboard.modules.guid = require('guid')
--Then call generate() to make one in any of your scene files:
print(storyboard.modules.guid.generate());
If you come across any bugs or better ways of doing it, post em over on github and I'll fix/add them.
Replies
Epic! Thank you!
Hi, I have been using this but then I was having some strange errors and tracked it back to this module.
I then tested:
1 2 3 | for i = 1, 100, 1 do print(guid.generate()) end |
and after 20 loops it starts returning False.
In line 22 in the module you have:
if(guid.loops > 20) then return false; end
which is the cause of the problem I believe.



I like this! Really cool, it could be really useful for multiplayer games.
Regards,
Jordan Schuetz
Ninja Pig Studios