FANDOM


The [it] and [them] tiles are ideas I have only seen in Spark, and they try to make your kode look more natural as you write it. However, it is important to understand what information they will contain, because if you haven't set up the when side of your kode correctly, they may not contain any information at all.

The It TileEdit

The [it] tile looks at the when side of its line to see if it evaluates to either a single object or an object set. If so, then [it] refers to the object or the first object in the set. If an object or object set is not found, each parent rule is checked, starting with the nearest one, until either the value of [it] can be set, or there are no more parent lines to check.

Another interesting use of the [it] tile is in a [for each of] loop. If you loop over an object set, then you can use the [it] tile to refer to the current object.

http://kodeshare.com/YskN0b

The Them TileEdit

The [them] tile works similarly to the [it] tile, except it treats what is found as an object set.

Some UsesEdit

One of the most common ways to use the [it] tile is to check if an object exists in your when section, then to do something.

http://kodeshare.com/jLpCzJ

This line checks to see if you have an object defined as [My Enemy], and if you do, shoots at it.

Another very common way of using both the it and them tiles are with sensors. Lets look at this line:

http://kodeshare.com/IoZNh7

This could be for something like a fire zone your character puts on the ground. The [them] tile is referring to the enemies found in the trigger zone.

You could use [it] in place of [them] above, which would choose just one enemy out of the set. You could also be looking for a specific object to enter the trigger zone instead like this.

http://kodeshare.com/HroCZi

Note: [global] [player] is an object variable that has been defined, and not the custom [player] tile.

Common MistakesEdit

Please note an easy mistake to make here: Checking if your object set has a count greater than 0, or that your object variable is not equal to nothing will *not* set your [it] tile. Let's take a quick look at why.

http://kodeshare.com/kyHijx

The When side above is evaluating to a boolean. It is either true or false, and therefore is *not* going to set the [it] tile, so the object will never jump. However, we can update the kode to be:

http://kodeshare.com/4Ak749

This will work, because the when side evaluates to the object variable and so the [it] tile is set.

This is the same as the object set example.

http://kodeshare.com/s0gGVQ

The use of [greater than] changes the result of the expression into a boolean rather than an object set, which doesn't allow the [them] tile to function. Therefore the above kode will NOT work as intended. Instead, you need this kode:

http://kodeshare.com/3wiJxc

If the enemies object set is nonempty, [them] will be set to that object set and therefore the nearest object inside [them] will be displayed correctly.

Small correctionEdit

Even though it may look like it, the [it] and [them] tiles don't work as described in the first two sections. You can find a thorough explanation of how they are actually set in this topic: Undefined variable and it/them behaviour.



It vs Them in Project Spark-003:34

It vs Them in Project Spark-0


Read NextEdit

Tiles That Reset


Further ReadingEdit

Timing and Logic

Brain Tiles


< Back to Koding Curriculum

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.