Module block

Block related variables and functions

Functions

move (direction, moveDelay, movePlayer) Tries to move the block to a specified direction.
teleportto (xpos, ypos, removecurrentblock, removetargetspot) Teleports the block in the given direction.
vanish (time) Makes the block vanish and reappear later.
explode (damage, vel) Makes the block explode, damaging the player in the process.
crumble (particles, damageModifier, damageThreshold) Calculates crumble damage to the block depending on the player's velocity.
shatter () Destroys the block by shattering it.
getblock (x, y, keepPlayerReference) Finds another block by given coordinates.
setmetadata (key, value) Sets a metadata with a specified key-value pair to the block.
getmetadata (key, defaultValue) Gets a block metadata value with the specified key.

Fields

health Current health of the block.
paused Is the block paused?
canmove Can the block be moved


Functions

move (direction, moveDelay, movePlayer)
Tries to move the block to a specified direction. Move delay and the option to move the player can be passed, too.

Parameters:

  • direction string The direction to move the block to.
  • moveDelay number The delay of how long it takes to the block to be able to be moved again. By default 100 (ms).
  • movePlayer boolean Is the player also moved? By default false.

Returns:

    boolean Returns whatever the move was successful

Usage:

  • block.move("right")
  • block.move("right", 200, true)
teleportto (xpos, ypos, removecurrentblock, removetargetspot)
Teleports the block in the given direction. NOTE: This is only client-side, meaning this function will only work on the person's client who touched the block.

Parameters:

  • xpos int The amount to move the block among the x-axis.
  • ypos int The amount to move the block among the y-axis.
  • removecurrentblock boolean If the original block should be deleted among a successful teleportation. True by default.
  • removetargetspot boolean If true, the teleporting block teleports to its specified location and deletes the block if its spot is taken up. False by default.

Returns:

    boolean Returns whether the move was successful.

Usage:

    block.teleportto(0, -7, false, true)
vanish (time)
Makes the block vanish and reappear later. The vanish delay can be passed.

Parameters:

  • time int The amount of time until vanishing. Vanishes instantly by default.
explode (damage, vel)
Makes the block explode, damaging the player in the process.

Parameters:

  • damage int The amount of damage done to the player. By default 1.
  • vel number The strength of the impact that pushes the player. By default 0.3.

Usage:

    block.explode(3, 1.1)
crumble (particles, damageModifier, damageThreshold)
Calculates crumble damage to the block depending on the player's velocity. Causes the block's health to drop and shatters the block if it goes to zero or below.

Parameters:

  • particles boolean Whatever to show particles when damage. By default true.
  • damageModifier number Modifier used to calculate the velocity to damage. By default 100.
  • damageThreshold number The threshold for how high the damage has to be to damage this block. By default 7.

Usage:

    block.crumble(true, 120, 20)
shatter ()
Destroys the block by shattering it.
getblock (x, y, keepPlayerReference)
Finds another block by given coordinates. A player reference can be passed.

Parameters:

  • x int How many blocks to the right the wanted block is?
  • y int How many blocks downwards the wanted block is?
  • keepPlayerReference boolean Is the player reference kept? By default false.

Returns:

    The found block as an object. Returns nil if a block isn't found.

Usage:

    block.getblock(0,-1).shatter()
setmetadata (key, value)
Sets a metadata with a specified key-value pair to the block.

Parameters:

  • key string Name of the metadata variable (the key)
  • value Value of the metadata variable

Usage:

  • block.setmetadata("coins", 10)
  • block.setmetadata("block name", "aqua")
getmetadata (key, defaultValue)
Gets a block metadata value with the specified key.

Parameters:

  • key string The key (metadata variable name) that's used to find its value.
  • defaultValue The value to return if the searched key does not exists. By default no specific value is returned.

Returns:

    Returns the key's value. Returns defaultValue instead if the key isn't found.

Usage:

  • block.getmetadata("coins", 0)
  • block.getmetadata("block name", "unnamed")

Fields

health
Current health of the block. The block is shattered if its health goes to zero or below.
paused
Is the block paused? Paused blocks can't move or change into different blocks.
canmove
Can the block be moved
generated by LDoc 1.4.6 Last updated 2019-09-24 19:24:02