How do I get my game to save names?

0 favourites
From the Asset Store
You must shoot down the enemy planes and eliminate them to earn points.
  • Hi! I'm new to Construct 2 and I need to know how to get my game to save a name the player types in so the game knows what to call you later on. I want to know how to save just the name (because this is before the game even starts) and if possible, how to add saving in general.

    Also, how do I make it so characters will say the name that the player choose during dialogue? For example: "Hi (name)! How are you?" Like that.

    Thanks in advance!

    MKP1000

  • First, to save a name you probably want to save it in a global variable. To build a string, you can use &. So set text to "Hi "&NameVariable&"! How are you?"

    To save and load, the simplest method is to use the system save and load actions. Local storage is more complex, but gives you more fine control over what to save and load.

  • First, to save a name you probably want to save it in a global variable. To build a string, you can use &. So set text to "Hi "&NameVariable&"! How are you?"

    To save and load, the simplest method is to use the system save and load actions. Local storage is more complex, but gives you more fine control over what to save and load.

    Hi again! Now how exactly would I do that? I apologize, I'm new to this. So I have a text box and a button. My goal is to have it save when I click the button. I make the global string where exactly?

    Thanks again,

    MKP1000

  • Global variable: right click on your event sheet and add variable (text).

    Event condition:

    Button - On button clicked

    Event action:

    System - Set variable to TextBox.Text

  • Global variable: right click on your event sheet and add variable (text).

    Event condition:

    Button - On button clicked

    Event action:

    System - Set variable to TextBox.Text

    OK! When I try to set the value to &.namevariable& it actually gives me a syntax error. Any ideas on how to fix this? Do I make that the value or the initial value? Whatever one it's not, what do I do there?

  • Ah that . in my post was a period. Follow what I wrote here - "Hi "&NameVariable&"! How are you?"

  • Ah that . in my post was a period. Follow what I wrote here - "Hi "&NameVariable&"! How are you?"

    Thank you so much for all the help! One last thing though. What do I set the initial value as?

    EDIT: So I have this:

    Global Text Name = &Namevariable&

    Button- On clicked

    The problem is, when I try to get to give a save command with that string it gives me an error.

  • Default name? I imagine you won't actually need to use this variable until after the player has set their name, so it shouldn't be an issue. You could probably leave it blank even if that's the case.

  • The Global Text name should just be NameVariable.

    & is used to put strings and expressions together (for when you need to display it later).

    Edit: quick example - https://www.dropbox.com/s/ixxhux3nofbsb ... .capx?dl=0

  • The Global Text name should just be NameVariable.

    & is used to put strings and expressions together (for when you need to display it later).

    Edit: quick example - dropbox.com/s/ixxhux3nofbsb ... .capx?dl=0

    Ah, OK. I think that'll do the trick. Thanks!

    One last edit: OK so I have to set it, but what do I set it with?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Event action:

    System - Set variable to TextBox.Text

  • The Global Text name should just be NameVariable.

    & is used to put strings and expressions together (for when you need to display it later).

    Edit: quick example - dropbox.com/s/ixxhux3nofbsb ... .capx?dl=0

    OK so I have a problem. I'm trying to make it so that when you press the OK button, it saves the name and goes to the next screen at the same time.

    I have:

    Global Text as Name Variable

    Button- On clicked- Set name Variable to textbox.text

    Button- On clicked

  • >

    > Event action:

    > System - Set variable to TextBox.Text

    >

    Update: So I tried to get it to save the name and I don't think it worked. I have it set to:

    Global text: name

    Button- On clicked- Set Name to textbox.text

    Is that how I get the player's name to save? And if so, how do I make the button save the name and go to the next screen at the same time?

  • You're saving the text in text box, which would be whatever the player decides to enter as their name.

    You can add the action go to next layout in the same event.

    Have you done the beginner tutorials?

  • You're saving the text in text box, which would be whatever the player decides to enter as their name.

    You can add the action go to next layout in the same event.

    Have you done the beginner tutorials?

    Sadly, no I haven't. Some of the things I'm looking for aren't there.

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