Array Problem

Get help using Construct 2

Post » Mon Aug 05, 2013 1:34 am

I've been working on this problem for an hour now and have no clue why it will not work.


All I'm doing is saving an objects position into an array when a button is pressed. However it does not seem to be doing it all. The array size is 16,15,1 (I've tried much larger too) so I don't see how it could be outside of it. Also, I know it has something to do with saving because the element doesn't even exist in the .json file.
When I load the value later it doesn't think anything is there and just sets it to 0, 0. I'va also had a text object set to display the 2 values every tick (and it shows 0, 0).
Also, setting the values into X = 15+ will do this but X = 0-14 will work successfully.

If anyone knows what is happening, a fix would be greatly appreciated.EncryptedCow2013-08-05 01:38:05
B
44
S
13
G
7
Posts: 603
Reputation: 7,936

Post » Mon Aug 05, 2013 3:05 am

Are you loading the array from JSON somewhere in your event sheet? If you had saved an array of width 15 earlier and were loading that it would override the width of your array. Just a guess.
B
55
S
28
G
19
Posts: 1,520
Reputation: 25,540

Post » Mon Aug 05, 2013 3:06 am

@ramones Yes I am loading it from JSON, but I've saved the array as JSON when it was supposedly 16 wide and loaded that. Also I've checked the value of the array after it's set and before it's loaded but it's still 0,0.EncryptedCow2013-08-05 03:07:44
B
44
S
13
G
7
Posts: 603
Reputation: 7,936

Post » Mon Aug 05, 2013 3:24 am

Print out the width/height/depth of the array when the button is clicked. And make sure there's no stray spr_playerspawner at (0,0) and that there is a spr_playerspawner on the layout :)

Either the array is the wrong size and the value isn't being set when the button is clicked or the value is being set to 0. If the array is the correct size you could try setting the value to -1 and see if it changes.
B
55
S
28
G
19
Posts: 1,520
Reputation: 25,540

Post » Mon Aug 05, 2013 4:27 am

@ramones just did that. it was in fact setting the array back to 15,15,1 before it added the values. I added a set size right before the setting value, then got the value from the array after it was set. That fixed it BUT, now when I load the array from json, it's still getting 0,0 (but the array is 16 wide now when it loads)EncryptedCow2013-08-05 04:27:43
B
44
S
13
G
7
Posts: 603
Reputation: 7,936


Return to How do I....?

Who is online

Users browsing this forum: Evanetot, ItsAstro, mehrshadfarahani, Pulstar, wowsoundsg and 5 guests