Alice Community  

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

Thread Tools Display Modes
Object Position in List
Posts: n/a
Default Object Position in List - 05-04-2010, 06:23 PM

Is it possible to ask an object it's position in a list? So I can tell what Index to remove from the list.
Reply With Quote
Super Moderator
x2495iiii's Avatar
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 05-04-2010, 11:45 PM

Originally Posted by jediaction View Post
no, sorry
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.
Attached Files
File Type: a2w AskandRemove.a2w (1.16 MB, 15 views)

Reply With Quote
Senior Member
jediaction's Avatar
Status: Offline
Posts: 5,064
Join Date: Jul 2009
Location: Bel Air, Maryland
Default 05-05-2010, 09:04 AM

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

Reply With Quote

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 ©2021, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.