Pulling data from nested lists(?)

hankster112

  • Posts: 27
I am currently working with the raycast extension provided here (http://community.stencyl.com/index.php/topic,16734.0.html), and so far it is returning the values I need from it (the x and y coordinates of the first object it hits). However, I am unable to properly access these values from the list it creates.
Here is an example of the raycast making contact with a tile:
Code: [Select]
Source/scripts/ActorEvents_14.hx:465: [B2Fixture,[Actor 100000000,Terrain],491.692307692308,256,0,10,0.692307692307692]
This is what it prints out when it makes contact with multiple tiles/actors:
Code: [Select]
Source/scripts/ActorEvents_14.hx:239: [[B2Fixture,[Actor 30,Corner Detection],576.5,896,10,0,0.559587471352177],[B2Fixture,[Actor 0,LoadParkourTest],9.99999999999998,896,10,0,0.992360580595875],[B2Fixture,[Actor 0,LoadParkourTest],9.99999999999998,896,10,0,0.992360580595875],[B2Fixture,[Actor 100000000,Terrain],896,896,10,0,0.315508021390374],[B2Fixture,[Actor 100000000,Terrain],576,896,10,0,0.559969442322384]]
And here is the readme portion for the block I am using:
Quote
3. "ray cast" returns a list of raycast results, in order of first hit to last hit. Each result is its own list containing:
   0. The B2Fixture hit.
   1. The actor the fixture belongs to.
   2. The x of the collision.
   3. The y of the collision.
   4. The x normal of the collision.
   5. The y normal of the collision.
   6. The fraction along the line at which the collision occurred.
From what I can tell, it is nesting lists inside each other. How would I pull data from a list inside an existing list instead of just pulling an entire list and having it return null/unusable values?

Luyren

  • *
  • Posts: 2815
Code: [Select]
Get item #0 from (get item #1 from raycast list)In short, use the "get item in list" block as its own list, inside another "get item in list" block. If you only need to read the information, that should suffice.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

hankster112

  • Posts: 27
Thanks, this works, although you have the item numbers reversed; it should be "get item 2/3 from item 0 in list" instead.