if you haven't already, read the Koding Curriculum
, which is the tutorial to begin working with Kode.
I suppose you are using the [inventory] tile, this is just an object set, so you can simply go through it with a for each of loop and use a variable [number var:
number of apples] that you increment by 1 every time you get an apple. But how do you know an object is an apple? I'm glad you asked.
To test if an object "test object" is an apple, DO NOT test if "test object" is equal to the apple in the gallery: an object coming from the gallery picker is pretty much regarded as an object set rather than an actual object, so you actually want to test if "test object" intersects the apple in the gallery, or you can transform [gallery picker: apple] into a real object set by joining [all objects] after it, and then test if that contains "test object".
You could also have created your "test object" from a template, but in that case, you still cannot test if "test object" is equal to the template. And you cannot use [intersect] directly on the template either, because it's not regarded as an object set: a template is mostly regarded as an object that doesn't really exist in the game. However, you can still get the object set of all objects created from that template with [template] [all objects], so you can do your test on that (using [intersect] or [contains]).
Finally, you can also look at the name of the object, and if it is the name that you gave to the apple or apple template in the first place, then it's probably an apple; just make sure you didn't give the same name to an object which is not an apple!
Okay, that's just one way to do it, but object sets are quite flexible: you don't need to look at each individual element to get the number of apples, instead you can directly calculate (without a for each of loop) the value of an intermediary [object set var:
apples in inventory] object set, and look at [object set var:
apples in inventory] [count].