Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DimitriyPS | |
Old Version | Published before Godot 3 was released. |
I need a string randomly generated from the specified character set, how to do it?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DimitriyPS | |
Old Version | Published before Godot 3 was released. |
I need a string randomly generated from the specified character set, how to do it?
Reply From: | Zylann |
Like this?
var character_set = ["a", "b", "c", "d"]
var length = 10
var s = ""
for i in range(0, length):
s += character_set[randi()%character_set.size()]
print(s)
You didn’t give much information, so that’s the only thing that came up to my mind^^
Yeah, that’s what I wanted. True… I invented the same thing, but was hoping for the string is a specialized method.
But your answer also confirms the rightness of my decision
DimitriyPS | 2017-05-03 20:38