PDA

View Full Version : Number-based requirement for interactions


maybesomethingdunno
17th Apr 2010, 04:10 AM
Yeah, perhaps not the most descriptive title...but I couldn't think of a better one. Let's say I have an object of GUID "123ABC". What would be the best way of creating an interaction or check that follows this pattern: "Do I have X objects in my inventory of GUID 123ABC? If so, proceed."

An example of what I'm trying to achieve: Once I have 5 individual "apple" objects (GUID 123ABC) in my inventory, I can convert them to a "basket of apples" object (GUID 456DEF). A basket cannot be made until this minimum requirement of apples is reached. The 5 apple objects would be removed from the inventory since they now compose the single basket object.

Does it make sense what I'm asking?

Echo
28th Apr 2010, 12:03 PM
I expect you'd just write a guard function which looped through inventory items, checked the type, then added one to a local variable each time you found an "apple". Then if that variable > 5 at the end of the loop, return true. :)

maybesomethingdunno
8th May 2010, 10:06 PM
Works like a charm. Thanks. :)