1.14.13 - Block

Blocks are solid map entities that may be pushed or pulled by the hero.

This type of map entity can be declared in the map data file. It can also be created dynamically with map:create_block().

Overview

Blocks that can move may be pushable, pullable or both pushable and pullable. A block can be moved either once or have an unlimited number of moves. It can be moved to any direction (the four main directions) or to a specific direction only.

The size of a block is always 16x16 pixels (the size of the hero), but as usual, its sprite may be larger.

Blocks are normally always moved by steps of 16 pixels. Thus, they can stay aligned on the 8x8 grid of the map. However, they may get stopped in the middle of their movement if they collide with entities like enemies or non-playing characters. In this case, they lose their alignment on the grid, and this might be a problem because you often want the to move a block precisely through narrow places and place it at an exact position to solve a puzzle. To deal with this potential issue, the engine automatically realigns the block to the 8x8 grid the next time it is moved.

Methods inherited from map entity

Blocks are particular map entities. Therefore, they inherit all methods from the type map entity.

See Methods of all entity types to know these methods.

Methods of the type block

The following methods are specific to blocks.

block:reset()

Restores the block at its initial position and resets its counter of moves.

It means that the hero will be able to move again a block that could be moved only once and that already moved.

block:is_pushable()

Returns whether this block can be pushed.

This property is independent of whether or not the block was already moved its maximum number of times.

block:set_pushable([pushable])

Sets whether this block can be pushed.

This property is independent of whether or not the block was already moved its maximum number of times.

block:is_pullable()

Returns whether this block can be pulled.

This property is independent of whether or not the block was already moved its maximum number of times.

block:set_pullable([pullable])

Sets whether this block can be pulled.

This property is independent of whether or not the block was already moved its maximum number of times.

block:get_maximum_moves()

Returns a value indicating the maximum number of times the block can be moved.

This function returns the maximum moves value that was set at creation time or by block:set_maximum_moves(), no matter if the block was moved then.

block:set_maximum_moves(maximum_moves)

Sets the maximum number of times the block can be moved.

This resets the remaining allowed moves.

Events inherited from map entity

Events are callback methods automatically called by the engine if you define them.

Blocks are particular map entities. Therefore, they inherit all events from the type map entity.

See Events of all entity types to know these events.

Events of the type block

The following events are specific to blocks.

block:on_moving()

Called when the hero starts moving the block of a step.

block:on_moved()

Called when the hero has just moved this block of a step.