Why does Number values from Lists turn to Objects? (ANSWERED)

docskull

  • Posts: 65
Hello there,

I am currently getting troubled by the values of a Game attribute of the "List" type. Their default values are all numbers and set to 15.

My code do not change this Game atributte but then, when the game saves and loads again, the values are not set to 15. A print of the values returns "[object Object]"

Do anyone knows why?

Thanks in advance


« Last Edit: January 21, 2012, 05:17:13 pm by docskull »

Dom818

  • *
  • Posts: 1296
I have also ran into this problem, I would also like to know why this does this. Any ideas?

rob1221

  • *
  • Posts: 9424
I don't know why that happens, but a workaround is to set each value of the list in a behavior.

Jon

  • *
  • Posts: 17524
You have to wrap them in 'as number' to get it working. The reason is that the lists aren't parameterized, so they can store any value. Retrieving the value will return it as the most generic type possible.

docskull

  • Posts: 65
Thanks Jon, it's all goin right now. :)