Pick Global Text (String) with variable

Get help using Construct 2

Post » Mon May 07, 2012 4:10 pm

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
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Mon May 07, 2012 7:45 pm

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)

Joe72012-05-07 19:51:53
B
14
S
6
G
5
Posts: 173
Reputation: 4,742

Post » Mon May 07, 2012 8:02 pm

@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.Nimtrix2012-05-07 20:04:33
B
27
S
8
G
8
Posts: 903
Reputation: 8,452


Return to How do I....?

Who is online

Users browsing this forum: Colorfish and 26 guests