Arrays could store strings?

Get help using Construct 2

Post » Mon Feb 18, 2013 11:10 am

I tried a simple thing.

System (on start of layout) -> Array (set value at 0 to "test")
                            -> Text (set text to str(Array.at(0))


But text displayed "0" instead of "test".
Could you help? Thanks.
B
21
S
8
G
6
Posts: 177
Reputation: 8,134

Post » Mon Feb 18, 2013 11:21 am

Should work, you can lose the str() when getting value from the array.
B
24
S
9
G
7
Posts: 756
Reputation: 7,312

Post » Mon Feb 18, 2013 11:49 am

The Array object does support strings. Are you sure you didn't make a zero sized array?
Scirra Founder
B
400
S
236
G
89
Posts: 24,549
Reputation: 195,475

Post » Mon Feb 18, 2013 11:56 am

Thanks vee41 and Ashley. Actually my code is like that

Empty event -> Array (set value at 0 to "test")
System (on start of layout) -> Text (set text to str(Array.at(0))

I'm planning a multi-level puzzle. All levels will share the same layout. I have an array that keeps all the levels info. When user skipped to new level, after the reset layout action, i don't want to reload array again.

So i put an empty event an the top of the event sheet. But in event order it still works as second i think
B
21
S
8
G
6
Posts: 177
Reputation: 8,134

Post » Mon Feb 18, 2013 1:24 pm

I think arrays are global by default, so if you just load your array at the beggining of the game it shouldn't be a problem.

Did you get this to work? I actually ran into something similar some time ago and I gave up when I noticed that the dictionary object was better for what I wanted to do (multiple lines of text).
B
125
S
43
G
41
Posts: 849
Reputation: 28,260


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, worm1 and 35 guests