amount of () in ()

From PenguinMod Wiki (Official)
Amount of () in ()
Jump to navigation Jump to search

The amount of () in () block is a reporter block in the Lists subcategory that reports the number of the entered item that is found in the list. For example:

when gf clicked
delete all of [names v]
add [Gobo] to [names v]
add [Scratch Cat] to [names v]
add [Tera] to [names v]
add [Pico] to [names v]
add [Tera] to [names v]
say (amount of [Tera] in [names v]::list) for (3) seconds //will say "2" for 3 seconds

The default value of this block is "foo". The block is case-sensitive, so if "Tera" in the input for this block was "tera" instead in the above example, it would have report 0 instead.

Workaround

This block can be worked around by iterating over the list, and seeing if the value is exactly equal to the wanted value:

define amount of (string) in list
set [index] to [0]::#0869c2
set [count] to [0]::#0869c2
repeat (length of [list v])
change [index] by (1)::#0869c2
if <(item (get [index]::#0869c2) of [list v]) = (string)> then
change [count] by (1)::#0869c2
end
end

See also