when ()

From PenguinMod Wiki (Official)
When ()
Jump to navigation Jump to search

This Block

Description

The when () block is a hat block that when the boolean inside it is true, it activates the code. However, the block doesn't always activate, it only activates once until the boolean is false again, then it will wait until the boolean is true again to activate.

Scratchblock

when <>::events

Workaround

This block can be worked around by using (timer/loudness) - <boolean> inside of a when [ v] > () block (since booleans that are true evaluate to 1 in equations and booleans that are false evaluate to 0:

when [timer v] > ((timer) - <bool::grey>)
...

when [loudness v] > ((loudness) - <bool::grey>)
...

An if statement in a forever loop also works, but this stops after the project ends:

when gf clicked
forever
if <bool::grey> then
...
wait until <not <bool::grey>>
end
end

The green flag is supposed to be a blue flag.

See also