Created
February 24, 2017 18:56
-
-
Save LunaSquee/ca33bc02c4b5baefe8fc815fc28f40a3 to your computer and use it in GitHub Desktop.
Godot utilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# UUID Generation | |
func generate_uuid(): | |
var repls = "xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx" | |
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | |
for c in range(0, repls.length()-1): | |
if repls[c] == "x": | |
randomize() | |
var rander = rand_range(1, chars.length()) - 1 | |
repls[c] = chars[floor(rander)] | |
return repls | |
# Random hash with length | |
func rand_hash(len): | |
var string = "" | |
var characters = "abcdefghijklmnopqrstuvwxyz1234567890" | |
for i in range(0, len): | |
randomize() | |
string += characters[rand_range(1, characters.length()) - 1] | |
return string | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment