How do I get arrays to stop hiding objects

Get help using Construct 2

Post » Mon Dec 28, 2015 2:48 am

Hi,

I am trying to use array data with other object. But each time I use the data on an object like a text or sprite the object disappears. here is the array being used.
It loads fine and the debugger says the variables are loading. But the objects that get the data disappear regardless of their type.

https://www.dropbox.com/s/rcumpvd8w9u17 ... p.PNG?dl=0

I'm not sure but I think this is a bug in the current version
B
10
S
2
Posts: 50
Reputation: 1,100

Post » Mon Dec 28, 2015 3:06 am

C2 uses 'loopindex' for the For loops. Change to For "" from 0 to 7
-> Set value at (loopindex,0) to ...

replacing your 'i' with 'loopindex.
You don't need the Add 1 to i.


https://www.scirra.com/manual/124/system-conditions
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Post » Mon Dec 28, 2015 3:19 am

Thanks,
But the data is loading fine. How would this stop the objects that use the data from vanishing as they are doing at the moment.
B
10
S
2
Posts: 50
Reputation: 1,100

Post » Mon Dec 28, 2015 3:29 am

Impossible to say from a screen shot. Can you isolate the code and post a CAPX?
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Post » Mon Dec 28, 2015 5:43 am

better still I'll explain my process and may be someone will show me the right way to do it.

I have a text file that is written like this.

200;
|
120;
|
420;
|
I am using the pipe "|" and the semicolon as separators. to split it up to the array called OAData.
So at OAData.At(1) the value will be 200 and the rest is etc'.

I then use that data t change sizes and positions. eg: Sprite12.x is set to 200 and so on.

How would you go about doing that? b'cause my code must break the C2 process.
B
10
S
2
Posts: 50
Reputation: 1,100

Post » Mon Dec 28, 2015 6:12 am

lukeo25 wrote:I have a text file that is written like this.

200;space,space,space,space...
|space,space,space,space...
120;space,space,space,space...
|space,space,space,space...
420;space,space,space,space...
|space,space,space,space...


try with trim
trim(src)
Return src with all whitespace (spaces, tabs etc.) removed from the beginning and end of the string.

set Array to...trim(tokenat(etc...))
Image
B
65
S
23
G
7
Posts: 1,501
Reputation: 10,888

Post » Mon Dec 28, 2015 6:29 am

tokenat() returns a string. You need to convert it to an int:
int(tokenat(...))
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Post » Tue Dec 29, 2015 12:10 am

Thanks for your help guys,

I did get this working using Set X to int(Array.At(o)).

Cheers
B
10
S
2
Posts: 50
Reputation: 1,100


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, JaredX, MikaelS, nahima, Yahoo [Bot] and 15 guests