I have created a Vector 2 and have a multdimensional array. I am then grabbing the x and y values of the Vector2 to perform a lookup in the Array. The problem is, it only half works and/or gives me an error. Can anyone see if I am doing something wrong or not doing something correct or is this some sort of issue?
Here is a rough example of what I am doing:
var grid = new Array();
grid.Push(new Array(1,1,1,1));
grid.Push(new Array(1,1,1,1));
grid.Push(new Array(1,1,1,1));
var tester = Vector2(2,2);
print (gridMap[tester.x][tester.y]);
The half works part is I can use either .x or .y to get the front part of the array but using both in combination gives me the error. In fact, I can even use the .x or .y and then use a number as the second accessor and it will work.
I understand that it shouldn’t work but it does for the first portion of it. For example:
var tester = Vector2(2,2);
print (gridMap[tester.x]);
That will return the proper item. So maybe this is something that should be checked when compiled?
Also, how do I do an inline float to integer conversion? In normal Javascript I could use parseInt, parseFloat and some others but those give me an error… I have tried Number, Integer, etc. and those all throw errors as well…
So as an example this is what I am doing when trying that conversion:
var tester = Vector2(2,2);
print (gridMap[Integer(tester.x)]);
or
print (gridMap[Number(tester.x)]);
or
print (gridMap[parseInt(tester.x)]);
You can do conversion to int like this. We are going to add parseInt and parseFloat with the next release.
var grid = new Array();
grid.Push(new Array(1,1,1,1));
grid.Push(new Array(1,1,1,1));
grid.Push(new Array(1,1,1,1));
var tester = Vector2(2,2);
function Start ()
{
var testerXInt : int = tester.x;
var testerYInt : int = tester.y;
print (grid[testerXInt][testerYInt]);
}