x position

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

The x position block is a reporter block in the Motion category that reports the current x position of the sprite that the block is in. It originates from Scratch. The default value for non-paint/blank sprites is a random position, while the default value for paint/blank sprites is 36. In the default project, the Penguin sprite starts at a position of (0, 0).

Workaround

This block can be worked around by using the () of () sensing reporter block, with x 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 x position of the main sprite, and not any of the clones:
[x position v] of (self v)
Or:
[x position v] of (join [se] [lf])
It can also be worked around by using a variable to save the value of the x position:

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

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

See also