Alice Community  

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

Reply
 
Thread Tools Display Modes
quick question about removing from lists
Old
necroth
Guest
 
Status:
Posts: n/a
Default quick question about removing from lists - 10-11-2009, 05:54 PM

Okay, so i made a list named "enemies"

there are 11 different enemies in that list. When my bullet "my_bullet" hits an enemy it sets its opacity to 0%.

How can i remove the ones from my list that have an opacity of 0%? Is this even possible?

or

How can i make the ones with opacity 0% in that list do stuff (like moving) while ignoring the ones with opacity 100%?
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 10-11-2009, 07:45 PM

You can remove an item with a "remove item from position <index> of <nameOfList>," which can be accessed by dragging the list from the properties window to the scripting area in Alice and clicking that option in the popup menu.
   
Reply With Quote
quick question about removing from lists
Old
bkk
Guest
 
Status:
Posts: n/a
Default quick question about removing from lists - 12-10-2009, 11:02 PM

Would the same hold true for an array? I have a number of creatures that move randomly, and turn invisible when zapped. The problem is, selection of which critter is going to move next is random from an array, and the fewer visible creatures that are left, the slower they seem to move since good old RNG is now more likely to pick an invisible critter.

Thanks!
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 12-10-2009, 11:55 PM

No, it wouldn't, because arrays don't have the same functions as lists do. There's a random item from list function you can use, why not use that?


(')>
   
Reply With Quote
ANS: quick question about removing from lists....
Old
bkk
Guest
 
Status:
Posts: n/a
Talking ANS: quick question about removing from lists.... - 12-11-2009, 08:00 AM

OK, I answered my own question, and yes, it came to me in a dream last night. Too much Alice. :-)

You can't remove an item from an array in Alice once the program has started.

However, since I have a statement that picks a random creature from the array, I simply check to see if that creature isVisible=true. If not, I roll another random number, then go on about my program.

Viola!
   
Reply With Quote
quick question about removing from lists...
Old
bkk
Guest
 
Status:
Posts: n/a
Default quick question about removing from lists... - 12-11-2009, 08:02 AM

I posted my reply before I saw yours, thanks for responding.

I had to use an array because the professor's assignment specified an array rather than a list.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 12-11-2009, 08:04 AM

Ah. That's too bad. In Alice, arrays are pointless, since they're just like lists, but not as functional.

Well, glad you got your problem solved anyway, good stuff.


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