Ryan
February 2, 2018, 4:19pm
#1
Just a small question as how to make this work. The way I’m trying to do this is by using console.log within a for loop of the array in question like so:
for(i=0;i<array.length;i++)
{
console.log(array[i]);
}
In the console it reads out [Object object] plus any other string or value I attach to the log.
mcmorry
February 2, 2018, 4:25pm
#2
you could just do console.log(JSON.stringify(array))
Ryan
February 2, 2018, 4:31pm
#3
Returns error: Converting circular structure to JSON
mcmorry
February 2, 2018, 4:34pm
#4
It seems that you have objects inside the array that are referring themselves.
Try just console.log(array)
and see if you can expand the row in the console.
Otherwise, set a breakpoint and inspect the value in debug mode.
Ryan
February 2, 2018, 4:50pm
#5
mcmorry:
console.log(array)
I’ve tried this, and it says the same thing only five times per line instead of once per line
scarlex
February 3, 2018, 6:43am
#6
console.log(array);
Should work. Your array is probably like this:
[
"[Object object]",
"[Object object]",
"[Object object]",
"[Object object]",
"[Object object]"
]
Ryan
February 5, 2018, 3:16pm
#7
That’s pretty much exactly what its doing, I’m trying to get it to print out the names of the objects though.
scarlex
February 5, 2018, 4:39pm
#8
Here is a simple demo.
How do you initialize your array ? And how do you print your array ?
Ryan
February 5, 2018, 4:46pm
#9
This is how I print the array.
I initialize the array like so:
dice = this.app.root.findByTag('Dice');
In the case of the actual script, array is replaced with dice, and my end goal is to get the console to print out Dice1 has stopped, Dice2 has stopped, etc. when the check confirms they have stopped moving. Or even if it could just say the objects position in the array.