DEV Community

SLOTH GAMES
SLOTH GAMES

Posted on

GODOT RANDOME NAME GENERATOR FROM LIST

Hello everyone...i am new on godot and i need your help..i want to make random name generator app with ready names like Jason, Cage, how can i code on Godot when i click a button labal must show random name ...please help how can i do that?

Top comments (1)

Collapse
 
shinspiegel profile image
Jeferson 'Shin' Leite Borges

My approuch would be, have two arrays, one with starters, and other with enders, shuffle and pick the first of each.

var starter = ["Ak", "Mac", "Shu"]
var enders = ["ful", "er", "or"]

func generate_name() -> String:
    starter.shufle()
    enders.shufle()

    return starter[0] + enders[0]
Enter fullscreen mode Exit fullscreen mode

This is the most basic idea, you could create more complex structures for names, and make special arrays for some specifc name, like elven list with two or three blocks (starter, mid, enders),