getting a js bug Array.Height to number

Just started using Construct 2? Post your questions here

Post » Wed Oct 01, 2014 11:38 pm

I am working on loading data into a array form AJAX and that seems to be working fine. but then I am trying to load the Array.Height into a number(int) var. and I get a js error when I run the page "set_int.without a number type" but I then do a loop from 0 to the var I set and that seems to work. please see attachment for what I am doing in the code
Capture.PNG
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 4
Reputation: 233

Post » Thu Oct 02, 2014 11:42 am

Sounds like you might have set the array sizes as strings instead of numbers in the JSON file:
Code: Select all
"size":["10","1","1"]
instead of
Code: Select all
"size":[10,1,1]
?
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Thu Oct 02, 2014 12:48 pm

Here is my array
{
"c2array": true,
"size": "[8,7,1]",
"data": [
[["Type"],["Y-Top"], ["X-Left"], ["Length"],["Dir"],["Movement"],["MovDir"]],
[["Plat"],["15"], ["0"], ["50"],["H"],["0"],["H"]],
[["Plat"],["15"], ["60"], ["20"],["H"],["0"],["H"]],
[["Plat"],["10"], ["79"], ["50"],["H"],["0"],["H"]],
[["Plat"],["27"], ["10"], ["30"],["H"],["0"],["H"]],
[["Plat"],["22"], ["36"], ["5"],["V"],["60"],["H"]],
[["Plat"],["29"], ["61"], ["15"],["H"],["100"],["V"]],
[["Latt"],["27"], ["40"], ["15"],["V"],["0"],["V"]]]
}
B
3
Posts: 4
Reputation: 233

Post » Thu Oct 02, 2014 12:51 pm

It should be
Code: Select all
"size": [8,7,1]
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Thu Oct 02, 2014 1:06 pm

Try int(MapArray.at(loopindex,2)).
B
28
S
8
G
4
Posts: 553
Reputation: 4,924


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests