How do I make a name picker?

0 favourites
  • 6 posts
From the Asset Store
HSV RGB Color Picker and Converter for Construct 3
  • Hey Guys,

    I am a total noob when it comes to programming with construct.

    The simple task I would like to create is a Name picker. Not a random name generator. But a program that lets you populate names into a field, hit a button and it spits out one of the pre-writen names you put into it.

    I have no idea where to start. Any help would be great.

    Thanks

  • I think you want Dictionaries (check the manual). I guess create textboxes for text entry and whenever text has been entered and confirmed, add it to a list of string variables stored in Dictionary form. Then when you select the button to spit out a random name, choose one of the stored strings or choose a random number which is assigned to a random string via Dictionaries.

  • just another alternative

    create a text variable textvar = Alex;John;Stephen;Helen;Tina;Josephine

    go get a random name from this use set name to tokenat(textvar,floor(random(tokencount(textvar,";"))),";")

    You also can add a simple input into the variable if you want.

    like set textvar to textvar&";"&textbox.text

    or another:

    array:

    (start with 0,1,1 sized array)

    when entering text: push array x back value = textbox.text

    when selecting a random name: set name to array.at(floor(random(array.width)))

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Have a look at arrays , and the random() expression , the routine would be populating a 1-dimensionnal array with strings , and then picking a random expression from the array via ;

    Array.At(random(0, Array.Width - 1))

    Important ; Arrays start at 0 , and not one , but the width is 1-based that's why I put Array.Width - 1

  • Thank you guys so much for your help. I will post the finished product soon.

  • Or the simplest:

    choose("name1","name2","name3","name4","name5","name6")

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)