Trying to use a global string "Name" on a second layout

0 favourites
  • 10 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hi, I'm trying to use a global string "Name" which stores the name inputted by the player. That works.

    Now I am trying to use that on another layout to have a custom message for the player.

    It does not work on the second layout. I would also like to have it displayed as the typewriter effect.

    The script is by someone I hired on Fiverr. But I'd like to have multiple layouts that use the players name in various text objects

  • Global variables should work in all layouts and all event sheets. Check if there is the "Reset global variables" action anywhere in the code.

  • No reset global variables.

    It's driving me nuts.

  • It does not work you mean the variable ? Or you mean it does not type anything ? Check the actions for 2nd layout are on the correct event sheet or one linked to the 2nd layout.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Bingo. The Layout and Event sheet were not connected.

    Thanks!

  • Add browser plugins.

    I suggest you add a lot of logs in each action and candition, you will see where the logs are disconnected.

    If you can't find it add as much as possible,

    Example logs 1 to 50, you will see

    1

    2

    3

    4

    23

    24

    25

    disconnected from log 4 you have to check.

  • O.K one bug smashed and another cropped up.

    I'm adding in the typewriter effect with the ^ to pause until a tap then the next part of the string loads in.

    Problem I have now is the Global Name &Name& is showing up as &Name& and not the saved name.

  • You can't use &Name& in declared variable.

    You can add your own tags, for example {name}, and then replace them with variables.

    Global string Name=Pete
    Global string Greeting=Hello {name}!
    
    Set Greeting to replace(Greeting, "{name}", Name)
    
  • I'm a bit confused about how to actually implement this?

    Global string Name=Pete

    Global string Greeting=Hello {name}!

    Set Greeting to replace(Greeting, "{name}", Name)

    My global string Name is left blank (this is working so far with a regular text action)

    The global string WelcomeTest is: Hello, "{name}", welcome back ^ Good to see you blah, blah, blah) the ^ pausing the typewriter effect and waiting for a tap to advance to the next line of text after the ^.

    I'm not understanding how you 'tag' or crete a tag and attach it to the Global string Name?

    drive.google.com/file/d/1Ja9QoWYrDUr7fUwBcpAQtGfqbUNetzrQ/view

  • The replace() expression replaced one substring with another. The {name} tag in my example is just the substring which will be replaced. It is not related to the Name variable in any way. You can use the word "banana" instead and it will work just the same.

    Global string s=Hello, banana!
    
    Set s to replace(s, "banana", playerName)
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)