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,114

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,232

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
373
S
218
G
84
Posts: 23,468
Reputation: 186,208

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,114

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
115
S
39
G
40
Posts: 828
Reputation: 27,408


Return to How do I....?

Who is online

Users browsing this forum: maf5713, Taser and 7 guests