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 to the given relative position.
teleporttopos (xpos, ypos, removecurrentblock, removetargetspot) Teleports the block to the given absolute position.
vanish (time, vanishduration) Makes the block vanish and reappear later.
explode (damage, vel, recovery) Makes the block explode, damaging the player in the process.
hurtplayer (damage, vel, recovery, checkRecovery) Makes the block hurt the player by a specific amount and with a specified velocity.
crumble (particles, damageModifier, damageThreshold) Calculates crumble damage to the block depending on the player's velocity.
shatter () Destroys the block by shattering it.
dye (color, duration, alpha) Applies paint to the block, altering its appearance until the paint wears off.
blackhole (duration, strength, offsetx, offsety, speedx, speedy) Summons a (client-sided) black hole.
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
xpos The absolute x-position of the block.
ypos The absolute y-position of the block.


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 to the given relative position. 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)
teleporttopos (xpos, ypos, removecurrentblock, removetargetspot)
Teleports the block to the given absolute position. 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 x-position to teleport the block to.
  • ypos int The y-position to teleport the block to.
  • 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.teleporttopos(0, -7, false, true)
vanish (time, vanishduration)
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.
  • vanishduration int The amount of time it takes for the block to reappear after being vanished. 2000 by default.
explode (damage, vel, recovery)
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.
  • recovery number The number of seconds the player takes to recover. By default 2.5.

Usage:

    block.explode(3, 1.1)
hurtplayer (damage, vel, recovery, checkRecovery)
Makes the block hurt the player by a specific amount and with a specified velocity.

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.
  • recovery number The number of seconds the player takes to recover. By default 2.5.
  • checkRecovery bool Prevents pushing the player if they have invulnerability received by recovering from damage. By default true.

Usage:

    block.hurtplayer(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.
dye (color, duration, alpha)
Applies paint to the block, altering its appearance until the paint wears off.

Parameters:

  • color int The decimal (or hex) value of the RGB color of the paint. By default 16777215.
  • duration int How long does the paint last? By default 999999.
  • alpha number Strength of the paint, ranges from 0 to 1.

Usage:

    block.dye(255, 50, 0.5)
blackhole (duration, strength, offsetx, offsety, speedx, speedy)
Summons a (client-sided) black hole.

Parameters:

  • duration number The duration of the black hole. By default 9900.
  • strength number The strength of the player pulling/pushing effect of the black hole. By default 1.
  • offsetx int How many blocks away to the right does the black hole spawn? By default 0.
  • offsety int How many blocks away downwards does the black hole spawn? By default 0.
  • speedx int How fast does the black hole move to right? By default 0.
  • speedy int How fast does the black hole move downwards? By default 0.

Usage:

    block.blackhole(9900, 1, 0, 0, 0, 0)
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
xpos
The absolute x-position of the block.
ypos
The absolute y-position of the block.
generated by LDoc 1.4.6 Last updated 2022-07-11 01:44:20