**This is an old revision of the document!**

Component: Debug

This component is provided by the Debug Card.

Component name: debug.

The Debug Card, which is only available in creative mode, provides a set of fairly dangerous functionality for use in setting things up to debug and test code. Do not use the Debug Card without backups. No, really. One time I accidentally converted a vertical slice of the world entirely to Sign objects with no writing on them.

The debug card's “container” refers to the robot, computer or tablet with a debug card installed in it.

Callbacks:

  • changeBuffer(value:number):number
    Changes the component network's energy buffer by the specified delta.
  • connectToBlock(x:number, y:number, z:number):boolean
    Connect the debug card to the block at the specified coordinates.
  • getPlayer(name:string):userdata
    Get the entity of a player.
  • getPlayers():table
    Get a list of currently logged-in players.
  • getWorld([id:number]):userdata
    Get the world object for the specified dimension ID, or the container's.
  • getWorlds():table
    Get a list of all world IDs, loaded and unloaded.
  • getX():number
    Get the container's X position in the world.
  • getY():number
    Get the container's Y position in the world.
  • getZ():number
    Get the container's Z position in the world.
  • isModLoaded(name:string):boolean
    Get whether a mod or API is loaded.
  • runCommand(command:string):number
    Runs an arbitrary command using a fake player.
  • test():userdata
    Test method for user-data and general value conversion.

World Object

The world object reflects the current world (dimension) the container is in.

  • getMetadata(x:number, y:number, z:number):number
    Get the metadata of the block at the specified coordinates.
  • getBlockId(x:number, y:number, z:number):number
    Get the ID of the block at the specified coordinates.
  • getDimensionId():number
    Gets the numeric id of the current dimension.
  • isLoaded(x:number, y:number, z:number):number
    Check whether the block at the specified coordinates is loaded.
  • getSeed():number
    Gets the seed of the world.
  • removeFluid(amount:number, x:number, y:number, z:number, side:number):boolean
    Remove some fluid from a tank at the specified location.
  • insertFluid(id:string, amount:number, x:number, y:number, z:number, side:number):boolean
    Insert some fluid into the tank at the specified location.
  • getDimensionName():string
    Gets the name of the current dimension.
  • getTime():number
    Get the current world time.
  • setTime(value:number)
    Set the current world time.
  • getLightValue(x:number, y:number, z:number):number
    Get the light value (emission) of the block at the specified coordinates.
  • isRaining():boolean
    Returns whether it is currently raining.
  • setRaining(value:boolean)
    Sets whether it is currently raining.
  • isThundering():boolean
    Returns whether it is currently thundering.
  • setThundering(value:boolean)
    Sets whether it is currently thundering.
  • setBlock(x:number, y:number, z:number, id:number or string, meta:number):number
    Set the block at the specified coordinates.
  • setBlocks(x1:number, y1:number, z1:number, x2:number, y2:number, z2:number, id:number or string, meta:number):number
    Set all blocks in the area defined by the two corner points (x1, y1, z1) and (x2, y2, z2).
  • removeItem(x:number, y:number, z:number, slot:number[, count:number]):number
    Reduce the size of an item stack in the inventory at the specified location.
  • insertItem(id:string, count:number, damage:number, nbt:string, x:number, y:number, z:number, side:number):boolean
    Insert an item stack into the inventory at the specified location. NBT tag is expected in JSON format.
  • getSpawnPoint():number, number, number
    Get the current spawn point coordinates.
  • setSpawnPoint(x:number, y:number, z:number)
    Set the spawn point coordinates.
  • canSeeSky(x:number, y:number, z:number):number
    Get whether the block at the specified coordinates is directly under the sky.
  • getLightOpacity(x:number, y:number, z:number):number
    Get the light opacity of the block at the specified coordinates.
  • hasTileEntity(x:number, y:number, z:number):number
    Check whether the block at the specified coordinates has a tile entity.

Player Object

A player object represents a given player in the world.

  • getWorld():userdata
    Get the player's world object.
  • getGameType():string
    Get the player's game type.
  • setGameType(gametype:string)
    Set the player's game type (survival, creative, adventure).
  • getHealth():number
    Get the player's health.
  • setHealth(health:number)
    Set the player's health.
  • getMaxHealth():number
    Get the player's max health.
  • getPosition():number, number, number
    Get the player's position.
  • setPosition(x:number, y:number, z:number)
    Set the player's position.
  • getExperienceTotal():number
    Get the player's total experience
  • getLevel():number
    Get the player's level
  • addExperienceLevel(level:number)
    Add a level to the player's experience level
  • removeExperienceLevel(level:number)
    Remove a level from the player's experience level
  • insertItem(id:string, amount:number, meta:number[, nbt:string]):number
    Adds the item stack to the players inventory
  • clearInventory()
    Clear the players inventory