Item () of ()
item () of [ v]
Category List
Type Reporter
Introduced in 1.3

The Item () of () block is a List block and a Reporter block. The block reports the value of the specified entry in a specified list. It is one of only two reporter blocks that can be inserted into a boolean input, the other one being the Item # of () in () block.

Example Uses

When a certain item in a list must be recalled, this block can be used.

Some common uses for the block are:

  • Reporting an object
ask [Which item would you like on our menu today?] and wait
change [cost v] by (item (answer) of [food costs v])
say (join (join [We'll be making your ](item (answer) of [food names v]))[ in a minute.])
  • Recalling part of a record
ask [What highscore would you like to know?] and wait
say (join (join (join [Highscore ](answer))[ is: ])(item (answer) of [highscores v]))
  • Comparing different items
if <(item (1) of [collection v]) = (item (1) of [pack v])> then
say [I already have this item in my pack.] for (3) secs

In a Boolean Input

This block can be inserted into a boolean input, despite being a reporter block. This is the only block with this special property, aside from Item # of () in ().

This can be useful if the condition needs to be changable. To let the condition be analog to

 if <key (space v) pressed> then 

, this can also be done:

if (item (1) of [conditions v]) then
...
end

Then, add the following code:

When green flag clicked
forever
if <(cond) = [1]> then
replace item (1) of [list v] with <key (space v) pressed>
end
if <(cond) = [2]> then
replace item (1) of [list v] with <key (q v) pressed>
end
end

Then, the only code needed is code needed to change the "cond" variable depending on something to let it work.

Special options

Special options exist which can be used by inserting a boolean block in the boolean input.

Random

(item (join[random]()) of [list v])

This makes the block chooses a random item in the list. This functionality can be replicated with the following code:

(item (pick random (1) to (length of [list v])) of [list v])

Last

(item (join[last]()) of [list v])

This makes the block chooses the last item in the list. This functionality can be replicated with the following code:

(item (length of [list v]) of [list v])//only if length of list > 0

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.