Debug Card: Difference between revisions
Unify item and component API pages |
m SoraFirestorm moved page Item/debug card to Debug Card without leaving a redirect: Page has been unified |
(No difference)
| |
Revision as of 21:03, 10 September 2026
Debug Card
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.
On a dedicated server the debug card must be bound to a player by shift-right-clicking with it to run commands using the runCommand callback. The bound player needs to have permission to use the command provided to runCommand.
Component API
Component: debug
changeBuffer
changeBuffer(value:number):number
Changes the component network's energy buffer by the specified delta.
connectToBlock
connectToBlock(x:number, y:number, z:number):boolean
Connect the debug card to an opencomputers-compatible block at the specified coordinates.
getPlayer
getPlayer(name:string):userdata
Get the entity of a player.
getPlayers
getPlayers():table
Get a list of currently logged-in players.
getWorld
getWorld([id:number]):userdata
Get the world object for the specified dimension ID, or the container's.
getWorlds
getWorlds():table
Get a list of all world IDs, loaded and unloaded.
getX
getX():number
Get the container's X position in the world.
getY
getY():number
Get the container's Y position in the world.
getZ
getZ():number
Get the container's Z position in the world.
isModLoaded
isModLoaded(name:string):boolean
Get whether a mod or API is loaded.
runCommand
runCommand(command:string):number, string
Runs an arbitrary command using a fake player. The first return value will be 1 if the command ran successfully, or 0 otherwise. The second return value will contain what the command returned, or an error message. If the command doesn't return anything, such as /me, the second value will be nil.
test
test():userdata
Test method for user-data and general value conversion.
getScoreboard
getScoreboard():userdata
Get the scoreboard object for the world
sendToDebugCard
sendToDebugCard(address:string, data...)
Sends data to the debug card with the specified address.
sendToClipboard
sendToClipboard(player:string, text:string)
Sends text to the specified player's clipboard if possible.
scanContentsAt
scanContentsAt(x: number, y: number, z: number[, worldId: number]):boolean, string, table
Returns contents at the location in world by id (defaults to host world). This method behaves the same as the move check for the robot and drone. The first return value is a boolean indicating whether a robot or drone would be able to enter the location (true means it would be blocked and cannot move into that space). The second return is a string value short name of the type of obstruction. Possible values here include: EntityLivingBase, EntityMinecart, air, liquid, replaceable, passable, and solid.The final value returned is a serialized or table representation of the entity or block scanned at the location. The following code snippet can be used to debug what is possibly blocking the robot from moving forward, if the robot is facing in the negative x direction.
local debug = require("component").debug
local serialize = require("serialization").serialize
local x, y, z = debug.getX, debug.getY, debug.getZ
local offset_x = -1
local offset_z = 0
local blocking, label, content = debug.scanContentsAt(x() - .5 + offset_x, y() - .5, z() - .5 + offset_z)
print(blocking, label, serialize(content))World Object
The world object reflects the current world (dimension) the container is in.
getMetadata
getMetadata(x:number, y:number, z:number):number
Get the metadata of the block at the specified coordinates.
getBlockId
getBlockId(x:number, y:number, z:number):number
Get the ID of the block at the specified coordinates.
getDimensionId
getDimensionId():number
Gets the numeric id of the current dimension.
isLoaded
isLoaded(x:number, y:number, z:number):number
Check whether the block at the specified coordinates is loaded.
getSeed
getSeed():number
Gets the seed of the world.
removeFluid
removeFluid(amount:number, x:number, y:number, z:number, side:number):boolean
Remove some fluid from a tank at the specified location.
insertFluid
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
getDimensionName():string
Gets the name of the current dimension.
getTime
getTime():number
Get the current world time.
setTime
setTime(value:number)
Set the current world time.
getLightValue
getLightValue(x:number, y:number, z:number):number
Get the light value (emission) of the block at the specified coordinates.
isRaining
isRaining():boolean
Returns whether it is currently raining.
setRaining
setRaining(value:boolean)
Sets whether it is currently raining.
isThundering
isThundering():boolean
Returns whether it is currently thundering.
setThundering
setThundering(value:boolean)
Sets whether it is currently thundering.
setBlock
setBlock(x:number, y:number, z:number, id:number or string, meta:number):number
Set the block at the specified coordinates.
setBlocks
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
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
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
getSpawnPoint():number, number, number
Get the current spawn point coordinates.
setSpawnPoint
setSpawnPoint(x:number, y:number, z:number)
Set the spawn point coordinates.
canSeeSky
canSeeSky(x:number, y:number, z:number):number
Get whether the block at the specified coordinates is directly under the sky.
getLightOpacity
getLightOpacity(x:number, y:number, z:number):number
Get the light opacity of the block at the specified coordinates.
hasTileEntity
hasTileEntity(x:number, y:number, z:number):number
Check whether the block at the specified coordinates has a tile entity.
playSoundAt
playSoundAt(x:number, y:number, z:number, sound:string, range:number)
Play a sound at the specified coordinates.
getTileNBT
getTileNBT(x:number, y:number, z:number):table
Get the NBT of the block at the specified coordinates.
setTileNBT
setTileNBT(x:number, y:number, z:number, nbt:table):boolean
Set the NBT of the block at the specified coordinates.
getBlockState
getBlockState(x:number, y:number, z:number[, actualState:boolean=false])
Gets the block state for the block at the specified position, optionally getting additional display related data
Player Object
A player object represents a given player in the world.
getWorld
getWorld():userdata
Get the player's world object.
getGameType
getGameType():string
Get the player's game type.
setGameType
setGameType(gametype:string)
Set the player's game type (survival, creative, adventure).
getHealth
getHealth():number
Get the player's health.
setHealth
setHealth(health:number)
Set the player's health.
getMaxHealth
getMaxHealth():number
Get the player's max health.
getPosition
getPosition():number, number, number
Get the player's position.
setPosition
setPosition(x:number, y:number, z:number)
Set the player's position.
getExperienceTotal
getExperienceTotal():number
Get the player's total experience
getLevel
getLevel():number
Get the player's level
addExperienceLevel
addExperienceLevel(level:number)
Add a level to the player's experience level
removeExperienceLevel
removeExperienceLevel(level:number)
Remove a level from the player's experience level
insertItem
insertItem(id:string, amount:number, meta:number[, nbt:string]):number
Adds the item stack to the players inventory
clearInventory
clearInventory()
Clear the players inventory
Scoreboard Object
addObjective
addObjective(objectiveName:string, objectiveCriteria:string)
Create a new objective for the scoreboard
removeObjective
removeObjective(objectiveName:string)
Remove an objective from the scoreboard
increasePlayerScore
increasePlayerScore(playerName:string, objectiveName:string, score:int)
Increases the score of a player for a certain objective
decreasePlayerScore
decreasePlayerScore(playerName:string, objectiveName:string, score:int)
Decrease the score of a player for a certain objective
addPlayerToTeam
addPlayerToTeam(player:string, team:string):boolean
Add a player to a team
removePlayerFromTeam
removePlayerFromTeam(player:string, team:string):boolean
Remove a player from a specific team
removePlayerFromTeams
removePlayerFromTeams(player:string):boolean
Remove a player from their team
addTeam
addTeam(team:string)
Add a team to the scoreboard
removeTeam
removeTeam(teamName: string)
Remove a team from the scoreboard
getPlayerScore
getPlayerScore(playerName:string, objectiveName:string):int
Gets the score of a player for a certain objective
setPlayerScore
setPlayerScore(playerName:string, objectiveName:string, score:int)
Sets the score of a player for a certain objective
Contents
| Items | |
|---|---|
| Components | Data Card - Debug Card - Graphics Card - Internet Card - Linked Card - Network Card - Redstone Card - Wireless Network Card |
| Storage Devices | Floppy Disk - EEPROM - Hard Disk Drive - Memory |
| Upgrades | Angel Upgrade - Battery Upgrade - Chunkloader Upgrade - Database Upgrade - Experience Upgrade - Generator Upgrade - Hover Upgrade - Inventory Controller Upgrade - Inventory Upgrade - Leash Upgrade - Navigation Upgrade - Piston Upgrade - Sign I/O Upgrade - Solar Generator Upgrade - Tank Upgrade - Tank Controller Upgrade - Tractor Beam Upgrade |
| Containers | Card Container - Upgrade Container - Disk Drive |
| Others | Analyzer - Texture Picker - Component Bus - CPU - APU - Drone Case - Manual - Microcontroller Case - Nanomachines - Remote Terminal - Terminal Server - Server - Tablet Case - Tablet - Crafting Materials - Ink Cartridge - Scrench - Hover Boots - Grog - Loot Disks |
