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
20
S
8
G
6
Posts: 176
Reputation: 8,047

Post » Mon Feb 18, 2013 11:21 am

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

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
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

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
20
S
8
G
6
Posts: 176
Reputation: 8,047

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
106
S
35
G
37
Posts: 798
Reputation: 25,215


Return to How do I....?

Who is online

Users browsing this forum: theosciandra and 23 guests