Pick Global Text (String) with variable

0 favourites
  • 3 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Hey guys, I'm currently working on a game where my levels are made out of a different combination of numbers represented by a string.

    Global text level1: "xxxxxxx"

    Global text level2: "xxxxxxx"

    etc..

    I was looking to change levels easily by using a variable "current_level", and an expression like this:

    "level" & current_level

    Similar to this solution for layouts.

    However, the expression only returns a string "level1" and won't identify it as the global text level1.

    So my question is: How can I get the expression to refer to the strings?

    Am I missing something obvious here, or is this currently not possible? Also, alternative solutions are very welcome.

    Thanks for all replies,

    Nimtrix

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why do you want to store the strings level1, level2, level1000,.. ?

    I would only store the number with a global number variable 'current_level' or perhaps I don't understand the question..

    What also should work is - if you have "levelnames" - is storing at the beginning all names in a global 1d-Array eg:

    myLevelNames_Array= ['The first one','Second','Final Stage']

    and load the right value on start of each layout to the current Layout:

    LevelLabel- set Text -> myLevelNames_Array.At(current_level-1)

    <img src="smileys/smiley2.gif" border="0" align="middle" />

  • Joe7:

    I could probably store the strings in an array, thanks for the suggestion.

    I want to store the levels in strings, because every string contains a value like "4|4|4|4|4|4|2|4|1|1|4|2|", where I use tokenat to seperate them and put them into an array. The array then defines how the level turns out. (unimportant)

    When starting level 1, I want to read the string "level1". The level will then be created according to the numbers in the string.

    Afterwards, I would like to increase my variable "current_level" to 2, and reset the layout. Then I'd like to read what's in the string "level2", in order to change my level without changing the layout.

    Hope that makes sense, thank you for replying.

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