RND generated string from the specified character set

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DimitriyPS
:warning: Old Version Published before Godot 3 was released.

I need a string randomly generated from the specified character set, how to do it?

:bust_in_silhouette: 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