此组件由调试卡提供。
仅在创造模式可用的调试卡提供了一套实际上很危险的功能,可用于调试与测试代码。没有进行备份的话切勿使用调试卡,绝对不要。比如有一次我就不小心将竖着的一整片世界都变成了无文字的告示牌。
调试卡的“容器”指装有调试卡的机器人、电脑或平板电脑。
在专用服务器游玩时,调试卡必须绑定到某个玩家身上才能用runCommand
回调来运行命令,绑定的方式为手持调试卡潜行右键单击。被绑定的玩家需要有运行提供给runCommand
的命令的权限。
组件名:debug
。
回调函数:
changeBuffer(value:number):number
connectToBlock(x:number, y:number, z:number):boolean
getPlayer(name:string):userdata
getPlayers():table
getWorld([id:number]):userdata
getWorlds():table
getX():number
getY():number
getZ():number
isModLoaded(name:string):boolean
runCommand(command:string):number, string
/me
,第二个返回值将为nil
。test():userdata
user-data
与通用数值的测试方法。getScoreboard():userdata
sendToDebugCard(address:string, data...)
sendToClipboard(player:string, text:string)
scanContentsAt(x: number, y: number, z: number[, worldId: number]):boolean, string, table
true
代表会被阻挡,不能进入)。第二个返回值为字符串值,代表障碍类型。可能的取值包括:EntityLivingBase
、EntityMinecart
、air
、liquid
、replaceable
、passable
、solid
。最后一个返回值为此位置扫描到的实体或方块,以序列化的或普通表的形式来表示。下面的代码片段可用于调试获取可能阻挡机器人前进的物体,假设机器人面向X轴负方向。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))
世界对象是容器当前所在的世界(维度)的映射。
getMetadata(x:number, y:number, z:number):number
getBlockId(x:number, y:number, z:number):number
getDimensionId():number
isLoaded(x:number, y:number, z:number):number
getSeed():number
removeFluid(amount:number, x:number, y:number, z:number, side:number):boolean
insertFluid(id:string, amount:number, x:number, y:number, z:number, side:number):boolean
getDimensionName():string
getTime():number
setTime(value:number)
getLightValue(x:number, y:number, z:number):number
isRaining():boolean
setRaining(value:boolean)
isThundering():boolean
setThundering(value:boolean)
setBlock(x:number, y:number, z:number, id:number or string, meta:number):number
setBlocks(x1:number, y1:number, z1:number, x2:number, y2:number, z2:number, id:number or string, meta:number):number
removeItem(x:number, y:number, z:number, slot:number[, count:number]):number
insertItem(id:string, count:number, damage:number, nbt:string, x:number, y:number, z:number, side:number):boolean
getSpawnPoint():number, number, number
setSpawnPoint(x:number, y:number, z:number)
canSeeSky(x:number, y:number, z:number):number
getLightOpacity(x:number, y:number, z:number):number
hasTileEntity(x:number, y:number, z:number):number
playSoundAt(x:number, y:number, z:number, sound:string, range:number)
getTileNBT(x:number, y:number, z:number):table
setTileNBT(x:number, y:number, z:number, nbt:table):boolean
getBlockState(x:number, y:number, z:number[, actualState:boolean=false])
玩家对象代表了世界中一个指定玩家。
getWorld():userdata
getGameType():string
setGameType(gametype:string)
survival
-生存,creative
-创造,adventure
-冒险)。getHealth():number
setHealth(health:number)
getMaxHealth():number
getPosition():number, number, number
setPosition(x:number, y:number, z:number)
getExperienceTotal():number
getLevel():number
addExperienceLevel(level:number)
removeExperienceLevel(level:number)
insertItem(id:string, amount:number, meta:number[, nbt:string]):number
clearInventory()
addObjective(objectiveName:string, objectiveCriteria:string)
removeObjective(objectiveName:string)
increasePlayerScore(playerName:string, objectiveName:string, score:int)
decreasePlayerScore(playerName:string, objectiveName:string, score:int)
addPlayerToTeam(player:string, team:string):boolean
removePlayerFromTeam(player:string, team:string):boolean
removePlayerFromTeams(player:string):boolean
addTeam(team:string)
removeTeam(teamName: string)
getPlayerScore(playerName:string, objectiveName:string):int
setPlayerScore(playerName:string, objectiveName:string, score:int)