Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
If/else and Arrays
Old
Ylu
Member
 
Status: Offline
Posts: 35
Join Date: Jul 2015
Unhappy If/else and Arrays - 07-30-2015, 12:22 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
   
Reply With Quote
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 212
Join Date: Dec 2012
Location: Frosno, Ca
Default 07-30-2015, 11:26 AM

Quote:
Originally Posted by Ylu View Post
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


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.