y position

From PenguinMod Wiki (Official)
Y position
Jump to navigation Jump to search

The y position block is a reporter block that reports the current y position of the sprite. It originates from Scratch. The default y position for paint sprites or blank sprites is 28, while other new sprites start at a random position. In the default project, the Penguin sprite is at (0, 0).

Workaround

This block can be worked around by using the () of () sensing reporter block, with y position selected, and getting the 2nd dropdown to be the sprite that the block is in. This can be achieved by using a reporter that reports the name of the sprite, or by copying the block from another sprite to the sprite wanted. However, this always gets the y position of the main sprite, and not any of the clones:
[y position v] of (self v)
Or:
[y position v] of (join [se] [lf])
It can also be worked around by using a variable to save the value of the y position:

define go to x: (xPos) y: (yPos)
set [current y v] to (yPos)
go to x: (xPos) y: (yPos)
define set y to (yPos)
go to x: (x position) y: (yPos)::custom
define change x by (y change)
set y to ((current y) + (y change))

These custom blocks would be used in place of the set y to (), go to x: () y: (), and the change y by () blocks. However, this does not account for the y limit of the sprite if remove fencing, or offscreen is disabled.

See also