How do I memorize a name to appear in dialogs?

0 favourites
  • 7 posts
  • hi,

    I'd like the player can enter his name at the start of the game, and then during the adventure, NPCs talk to him using this name in the middle of their multiple sentences.

    For example, at the start we name our character "HERO" and then during the game the NPC says: "hey HERO how are you?" Or to give a quest "HERO , can you get me this stuff?"

    SO how can I do that and insert a memorized name in the middle of any sentences ?

    thank you

  • try to save it on local storage then call it when it is needed

  • A global variable would be the easiest. You can get the name from the player with a Textbox object, and then set the global from that. So say you call the global variable "hero", you can then build the text the npc says with an expression like:

    "hey " & hero & " how are you?"

    hero & " , can you get me this stuff?"

    The key thing is "&", which combines values together as text.

  • Oh, thank you, I didn't know the "&" trick

    Problem solved, thx

  • One question more please :

    The only way to do that is to using the Events?

    For example :

    Text_Name ------ Set Text to "hey " & hero & " how are you?" (that is works well, thanks again

    Or can I use my sentence directly in the Properties box on the left of my Text_Name item ?

    So directly write in the Properties "hey " & hero & " how are you?" Unfortunally, if I do that, it doesn't work, but I was wondering if it was possible with a specific expression by any chance ? It's just because It's more simple to see directly all my texts in the Editor (else with the 1st method they are empty).

    Thx for your help

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can't use an expression like that when setting the text property in the editor. For that it's easier to do use some placeholder text and then replace it later with events.

    something like this:

    Hi $hero, do you like jalapeños?

    Then in events set text to replace(self.text, "$hero", heroNameGlobal)

  • Ohhh Ok i see... excellent idea ! thx very much for all your help

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