Alice Community

Alice Community (
-   How do I...? (
-   -   Object Position in List (

Michaelb089 05-04-2010 06:23 PM

Object Position in List
Is it possible to ask an object it's position in a list? So I can tell what Index to remove from the list.

x2495iiii 05-04-2010 11:45 PM

1 Attachment(s)
[QUOTE=jediaction;20778]no, sorry[/QUOTE]

Wrong. It can be done, you just have to look for it.

Drag the list onto the scripting area and you'll have the option to make a "Remove item from position [index] of [name of list]" method. Choose any index you want so the method will be created. Then, drag the list onto the index variable, and one of the options will be "First index of..." Using this, you can look for the first occurrence of a certain object. By combining it with the remove item method, you have a method which scans the list to see where the object is, then removes it accordingly.

I included a world with an example of the code I described.

jediaction 05-05-2010 09:04 AM

Had no idea, hey look, another thing i learned about alice, im always getting better. Thanks X

All times are GMT -5. The time now is 09:48 AM.

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