PDA

View Full Version : If/else and Arrays

Ylu
07-29-2015, 11:22 PM
I am currently working on if/else and was told to use

index= 0

loop # times

if item i from object is .1 meters away from object2
increment +1
end if

increment i
end loop

So I'm confused. I am trying to get redo a series of instructions but using the array instead of individual listing the objects is causing the if in the if/else equation not to function.

In the 2nd section - 2 objects are used
3rd section - 3 objects
4th section -4 objects

I have an array with all 4 but I am unable to get the it to differentiate b/w each object in the array (in one statement) without having to make a different statement for each.

Problem illustration

Old structure
if either object1 is within 5 meters of the car OR either object2 is within 5 meters of the car OR either object3 is within 5 of the car

New structure with problem

if either index item is within 5 meters of the car

Help, so tired of working on this

chickentree
07-30-2015, 10:26 AM
I am currently working on if/else and was told to use

index= 0

loop # times

if item i from object is .1 meters away from object2
increment +1
end if

increment i
end loop

So I'm confused. I am trying to get redo a series of instructions but using the array instead of individual listing the objects is causing the if in the if/else equation not to function.

In the 2nd section - 2 objects are used
3rd section - 3 objects
4th section -4 objects

I have an array with all 4 but I am unable to get the it to differentiate b/w each object in the array (in one statement) without having to make a different statement for each.

Problem illustration

Old structure
if either object1 is within 5 meters of the car OR either object2 is within 5 meters of the car OR either object3 is within 5 of the car

New structure with problem

if either index item is within 5 meters of the car

Help, so tired of working on this

Please upload a movie showing what you are trying to do as well as you are able. Also more information on the movies requirements would help.

If you have your array setup then make the method work with one object not using the array. Then, when the method is working, click on the array and drag it to everywhere the object you've been using appears in the method and select "ith item from array" setting i to a value between 0 and 3.
Finally replace the index you used (0,1,2 or 3) with your index variable in the method.

Mark