In other languages

Help the wiki!

The Scratch Wiki is made by and for Scratchers. Do you want to contribute?

Learn more about joining as an editor!

See discussions in the Community Portal

Change () by () (block)

Change () by ()
2.0 Change () by ().png
Category Variables
Type Stack

The Change () by () block is a Variables block and a Stack block. The block will change the specified variable by a given amount. If the variable is a string and not a number, it is set to the quantity the variable was to be changed by (casting the string to 0).

Prior to Scratch 1.3, this block didn't have a drop-down input listing the variables and instead there was an instance of it for each variable.

Change () by () (1.0).png

Example Uses

Some common uses for the Change () by () block:

  • Changing the speed of an object
set [speed v] to (2)
set x to (-240)
forever
  change x by (speed)
  change [speed v] by (1)
  say [Whee!!!]
  • Changing a level number
if (touching [goal v]?) then
  change [level v] by (1)
end
  • Changing the score in a game
if (touching [laser v]?) then
  change [score v] by (-5)
end

Workaround

Main article: List of Block Workarounds

This block can be replaced by the following script:

set [variable v] to ((variable) + (amount))

The blank space at the far right contains the number that will change the value—a positive number to increase and a negative number to decrease the variable.

See Also

  • This page was last modified on 30 August 2014, at 06:46.