0 Favourites

Pick Global Text (String) with variable

  • 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

  • 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" />

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
[Plugin] tag text
188 25,455
RBuster's avatar
RBuster
Unread hot topic
118 32,905
rexrainbow's avatar
rexrainbow
Unread hot topic
102 6,404
Ashley's avatar
Ashley Construct Team Founder