A little explanation please and moving multiple objects

Hi, I’m back again for more “how does this work?/how do I do this?”
It’s 2 (well more kinda 3 or 4) things again, the first is with moving multiple objects, I have some money in a drawer which if it isn’t found I want it to be lost but rather than write

drawer.bigNote.moveInto(nil); drawer.smallNote.moveInto(nil); drawer.silverCoin.moveInto(nil); drawer.goldCoin.moveInto(nil); drawer.copperCoin.moveInto(nil);
I would rather be able to just move the contents of the drawer to nil or move the money as a collective into nil, but haven’t a clue really to how to go about it. I was hoping someone could explain to me about searching objects in a room or searching for objects that have a certain property or belong to a certain group… If they don’t mind that is :slight_smile:

The other one I wanted to ask about is… Kind of a puzzler… I have puzzle involving a glass tube with gems in (I’d post this but it’s pushing 200 lines long and I need help with just 2 of them), the gems can be taken out of either end and each end changes colour dependant on number of gems in it but are clear when they’re not in the tube. I’ve set it up so the gems in the tube are an abstract item (to allow for the description changing for the gems and the tube) and all worked fine but the problem(s) comes when adding an actual 10 gems to the game. When the player takes a gem I have the abstract ‘gems’ move a gem to the player (for the puzzle part it needs to be this way really)

prob 1 is when taking a gem it only moves the first gem to the player though all the messages are in tact (that’s if I have them in loc==nil, if I have them in the tube, it take the ‘class’ first ignoring the tube then takes 1 from nil so I end up with 2 gems and the descriptions saying there’s 9 in the tube instead of 8)

prob 2 is refering to the seperate gem once it’s out ‘look at gems’ works fine but if the ‘real’ gems are in the tube, look at gem produces

but if I store them in nil I either get a description of the gems (there are 8 gems, the 3 on the left glowing…) or

For the first one I’d preferably like to specify where they come from (like gem.moveOutOf(tube)into(gPlayerChar or something of sorts)
As for the 2nd I’m trying to make it so that the player can’t see or refer to the gems whilst they’re in the tube really (it’d be far easier) failing that a way of changing the vocab words for a gem not in the tube but I struggled doing that too since it isn’t part of an action on the actual gem

Does anyone know any quick fixes?

I’ve never tried this, but you might want to look at the Dispenser class. The discussion in the Tour Guide might be the place to start.

Oooh That looks handy actually, and it might just work Thanks Jim! :smiley:

It worked! Yaay thankies, I could pretty much take the bit I needed out of the RedCandle example and with tiny bit of tinkering with my code block to make it fit it works great, had to put (gems) in the vocabWords to make it work right which meant giving it a disambigName but now it works better than before ( I hadn’t thought someone might try to ‘remove’ them from the tube haha)

Thank youuuuuuu

This can be written as:

drawer.contents.subset({obj: obj.ofKind(Money)}).forEach({obj: obj.moveInto(nil)});

Drawer.contents is a list of objects that the drawer contains. subset and forEach are List methods. Here the contents list is first filtered down to a list of money objects in the drawer, and then each money object is moved into nil.

Thanks bcressey I knew there was an easy way, I had at some point tried to just write ‘drawer.contents.moveInto’ being hopeful that it might work. I’m gonna have to get used to using lists sooner or later and I won’t learn until I get stuck into them, looking at that makes me feel alot better now though. Up until now I’ve teetered around them a little (I’m used to being able to see lists)