Need Help understanding my VEX Code (For each Loop)

   1416   3   1
User Avatar
Member
42 posts
Joined: March 2019
Offline
Hello there, I wrote some VEX and need help to understand why it actually works

As you can see, I iterate over the points in a specific radius and then set the color of the attributes to Blue if one of the “nearpoints” has the attribute “heat” with a value of “1”
But why does this actually work. I don't understand why I have to put in the iteration number “num” instead of just “ptnum”
Is the order of the “ptnum” in the “foreach loop” reset? Or how can I understand this?

I'm sorry for my mediocre explanatory skills. I hope you still can understand it.
I very much appreciate your help guys.
Edited by Lucca - July 21, 2020 09:54:52

Attachments:
Unbenannt.PNG (26.8 KB)

User Avatar
Member
52 posts
Joined: June 2016
Offline
I think it's because you are looping though the npts array. So @ptnum don't have the same numbers. That's why you need the int num;
User Avatar
Member
6 posts
Joined: Nov. 2015
Offline
i@heat will only give you the heat attribute of the current point the wrangle is calculating and not the heat attribute of the found nearpoints. use int nearheat = point(0,“heat”,num); in the foreach loop for example.
Edited by Houseo_of_Secrets - July 21, 2020 19:14:08
User Avatar
Member
42 posts
Joined: March 2019
Offline
c0y
I think it's because you are looping though the npts array. So @ptnum don't have the same numbers. That's why you need the int num;


I tested a little bit to visualize what the “num” (so the iteration) is actually doing and found out that it is returning the actual value of the current index in the array. So if the array has values like "“ it actually returns those values, so the @ptnum still have the same numbers. That is also the reason why I can use it hear to turn the Color of the Points blue with ”num"

Thanks for your responses

Greetings Lucca
Edited by Lucca - July 22, 2020 05:13:15
  • Quick Links