Adding together two array values

Discussion and feedback on Construct 2

Post » Sun Jan 08, 2017 12:26 am

I noticed that if I try something like Array.At(0,0) + Array.At(0,1), I only get the value from Array.At(0,0) . If I reverse it I only get the value of Array.At(0,1). If I use something like Array.At(0,1) + 1 I have the same problem where only the first value is used and the other is ignored. I've tried putting both numbers inside parentheses but that didn't work either. What's the proper way to do this?
B
22
S
8
Posts: 203
Reputation: 2,059

Post » Sun Jan 08, 2017 12:35 am

Sounds like you have strings in your array and not numbers, so the math just fails.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Sun Jan 08, 2017 1:01 am

No, I'm using numbers for both values. The exact code is
On button clicked: Array set value at (0,0) to Array.At(0,0) + Array.At(0,1)

I'd expect every time the button is clicked for the value to increase by whatever the value at Array.At(0,1) is but it doesn't do that

If I turn Array.at(0,1) into a variable, A and then try
On button clicked: Array set value at (0,0) to Array.At(0,0) + A
The program then works
B
22
S
8
Posts: 203
Reputation: 2,059

Post » Sun Jan 08, 2017 2:20 am

Have a look at this. http://www.blackhornettechnologies.com/Construct2Stuff/NumberVSStringArray.capx
The debugger will show the same data even though they are not.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868


Return to Construct 2 General

Who is online

Users browsing this forum: bobcgausa and 14 guests