[r99] array breaks?

Bugs will be moved here once resolved.

Post » Sun Aug 05, 2012 8:59 pm

All,

I don't know if this is a bug, or just my lack of programming knowledge. I created as simple a capx as I could the illustrate the problem.

On program start, I define two arrays.
#1
box - (x,y,z)
x = statistics for box ie, maxHP, atk, def, etc,
y = boxes lvl, ie, 1, 2, 3, etc
z = which box, ie, red or orange

#2
curVar    - (x,y)
x = cur variables held, curHP, curLVL, curName, etc
y = which box, ie, red or orange

In my code, I use positions in the curVar array to call position in the statistics array,

For instance,

Example A
"HP: " & curvar_array.At(3,menu_box.box)& "/" & box_array.At(1,curvar_array.At(2,menu_box.box),menu_box.box)


and


Example B
"HP: " & curvar_array.At(3,select_box)& "/" & box_array.At(1,curvar_array.At(2,select_box),select_box)


Example A calls from the instance variable set on the text box to display the info in the array.

Example B calls from a global variable - select_box, which is defined based on where one clicks - to display the info in the array.

Example A works fine, but Example B breaks the code.


If the global variable - select_box - is set to 0, the code breaks even though I define the array at (0,0,0), but if on start of layout I set select_box to 999, the code works fine.

The error message I get is:

"THE PAGE AT THE LOCALHOST: 50000 SAYS:"

"Javascript error!
Uncaught TypeError; Cannot read property "0" of undefined
http://localhost:5000/Arr_pluging.js, line 102

This is either a bug in Construct 2 or a problem in a third party plugin or behavior - please report in to the developer!"


Here is the capx for reference:

https://dl.dropbox.com/u/70332704/arrayerrormsg.capx


Thanks for taking a look at thisbigpappapuck2012-08-11 22:35:38
B
11
S
2
G
2
Posts: 26
Reputation: 2,974

Post » Fri Aug 17, 2012 5:54 pm

Should be fixed in the next build. FYI it's because you are accessing arrays with NaN as an array index. (This is a sort of invalid value you get if you do things like divide a number by zero, since there is no possible result.) Now the array will just return 0 if you do that rather than causing that error, but you probably want to fix your events anyway.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Sun Aug 19, 2012 9:28 pm

Thanks Ashley!
B
11
S
2
G
2
Posts: 26
Reputation: 2,974


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest