Hello everyone, made this snippet for a multiplayer server system I was developing. It's pretty straight forward, generates a new UUID String according to the v4 spec
function CreateUUID()
nibbles as integer[31]
//Generates 128 random bits
for i=0 to 31
bit0 = Random(0,1)
bit1 = Random(0,1)
bit2 = Random(0,1)
bit3 = Random(0,1)
nibbles[i] = (bit3<<3)+(bit2<<2)+(bit1<<1)+bit0
next i
//Set the version number
nibbles[12]=nibbles[12]&&0x0
nibbles[12]=nibbles[12]||0x4
//Set the variant number
nibbles[16]=nibbles[16]&&0x3
nibbles[16]=nibbles[16]||0x8
nibbles[17]=nibbles[17]&&0xF
nibbles[17]=nibbles[17]||0x0
//Convert to Hex string
UUID$ = ""
for i=0 to 31
UUID$ = UUID$+hex(nibbles[i])
if(i=7 or i=11 or i=15 or i=19)
UUID$ = UUID$+"-"
endif
next i
endfunction UUID$