There's 141,167,100,000,000 possible combinations so it's unique by virtue of the fact you'd never use that many. Seriously, don't tell me you plan on using more.
Let me know if you find any bugs.
#define A 65
#define Z 90
var/last_tag = "AAAAAAAAAA"
datum
proc
GetTag()
// We need to make them a tag
if(tag == null)
tag = CreateTag()
last_tag = tag
// If they have one already, just return it.
return tag
proc
CreateTag()
var/current_char
var/new_tag = ""
for(var/i = 10; i >= 1; i--)
current_char = text2ascii(last_tag, i)
// A - X
if(current_char < Z)
// Increment and we're done
current_char++
new_tag = "[ascii2text(current_char)][new_tag]"
return copytext(last_tag, 1, i) + new_tag
// Z
else
// Turn over and keep going until we hit A - X
new_tag = "A[new_tag]"
// So you actually ran out of IDs. There was 141,167,100,000,000 possible combinations.
// Even I'm impressed. At this point it will roll back to the start.
return new_tag