Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
component:debug:zh [2023/10/24 04:51]
hfsr created
component:debug:zh [2023/12/10 16:06] (current)
hfsr [计分板对象]
Line 1: Line 1:
-Component: Debug+组件:调试
 ================= =================
-This component is provided by the [[item:​debug_card|Debug Card]]. +此组件由[[item:​debug_card:zh|调试卡]]提供。  ​ 
- +   
-Component name: `debug`. +仅在创造模式可用的[[item:​debug_card:zh|调试卡]]提供了一套实际上很危险的功能,可用于调试与测试代码。没有进行备份的话切勿使用调试卡,绝对不要。比如有一次我就不小心将竖着的一整片世界都变成了无文字的告示牌。  ​ 
- +   
-The [[item:​debug_card|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. +在专用服务器游玩时,调试卡必须绑定到某个玩家身上才能用`runCommand`回调来运行命令,绑定的方式为手持调试卡潜行右键单击。被绑定的玩家需要有运行提供给`runCommand`的命令的权限。  ​ 
- +   
-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. +组件名:`debug`。 ​  
- +   
-Callbacks:+回调函数: ​
  
 - `changeBuffer(value:​number):​number`  ​ - `changeBuffer(value:​number):​number`  ​
-  ​Changes the component network'​s energy buffer by the specified delta.+  ​以指定值作为增量,修改组件网络的能量缓存。 ​  
 +\\
 - `connectToBlock(x:​number,​ y:number, z:​number):​boolean`  ​ - `connectToBlock(x:​number,​ y:number, z:​number):​boolean`  ​
-  ​Connect the debug card to an opencomputers-compatible block at the specified coordinates.+  ​将调试卡连接到指定坐标处的可与 OC 兼容的方块。 ​   
 +\\
 - `getPlayer(name:​string):​userdata`  ​ - `getPlayer(name:​string):​userdata`  ​
-  ​Get the entity of a player.+  ​获取玩家对象。 ​  
 +\\
 - `getPlayers():​table`  ​ - `getPlayers():​table`  ​
-  ​Get a list of currently logged-in players.+  ​获取当前登录玩家列表。 ​  
 +\\
 - `getWorld([id:​number]):​userdata`  ​ - `getWorld([id:​number]):​userdata`  ​
-  ​Get the world object for the specified dimension ​ID, or the container'​s.+  ​获取指定维度ID对应的世界对象,若不指定则为容器的世界。 ​  
 +\\
 - `getWorlds():​table`  ​ - `getWorlds():​table`  ​
-  ​Get a list of all world IDs, loaded and unloaded.+  ​获取所有世界ID的列表,无论是否加载。 ​  
 +\\
 - `getX():​number`  ​ - `getX():​number`  ​
-  ​Get the container'​s ​position in the world.+  ​获取容器在世界中的X坐标。 ​  
 +\\
 - `getY():​number`  ​ - `getY():​number`  ​
-  ​Get the container'​s ​position in the world.+  ​获取容器在世界中的Y坐标。 ​  
 +\\
 - `getZ():​number`  ​ - `getZ():​number`  ​
-  ​Get the container'​s ​position in the world.+  ​获取容器在世界中的Z坐标。 ​  
 +\\
 - `isModLoaded(name:​string):​boolean`  ​ - `isModLoaded(name:​string):​boolean`  ​
-  ​Get whether a mod or API is loaded.+  ​获取指定modAPI是否加载。 ​  
 + \\
 - `runCommand(command:​string):​number,​ string`  ​ - `runCommand(command:​string):​number,​ string`  ​
-  ​Runs an arbitrary command using a fake player. The first return value will be if the command ran successfully,​ or 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.+  ​使用伪玩家(fake player)执行任意命令。若命令运行成功则第一个返回值为1,失败为0。第二个返回值为指令返回的内容或报错信息。若命令不返回任何内容,例如`/me`,第二个返回值将为`nil`。   
 +\\
 - `test():​userdata`  ​ - `test():​userdata`  ​
-  ​Test method for user-data ​and general value conversion.+  ​用于转换`user-data`与通用数值的测试方法。 ​  
 +\\
 - `getScoreboard():​userdata`  ​ - `getScoreboard():​userdata`  ​
-  ​Get the scoreboard object for the world+  ​获取世界的计分板对象。 ​  
 +\\
 - `sendToDebugCard(address:​string,​ data...)`  ​ - `sendToDebugCard(address:​string,​ data...)`  ​
-  ​Sends data to the debug card with the specified address.+  ​向指定地址的调试卡发送数据。 ​  
 +\\
 - `sendToClipboard(player:​string,​ text:​string)`  ​ - `sendToClipboard(player:​string,​ text:​string)`  ​
-  ​Sends text to the specified player'​s clipboard if possible.+  ​若可行的话,向指定玩家的剪切板中发送文本。 ​  
 +\\
 - `scanContentsAt(x:​ number, y: number, z: number[, worldId: number]):​boolean,​ string, table`  ​ - `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: ​EntityLivingBaseEntityMinecartairliquidreplaceablepassable, 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.+  ​返回指定ID对应世界(默认为主世界)指定位置处的内容。此方法与机器人和无人机的运动检测功能行为相同。第一个返回值为布尔型,代表了机器人或无人机能否进入此位置(为`true`代表会被阻挡,不能进入)。第二个返回值为字符串值,代表障碍类型。可能的取值包括:`EntityLivingBase`、`EntityMinecart`、`air`、`liquid`、`replaceable`、`passable`、`solid`。最后一个返回值为此位置扫描到的实体或方块,以序列化的或普通表的形式来表示。下面的代码片段可用于调试获取可能阻挡机器人前进的物体,假设机器人面向X轴负方向。
  
 <code lua> <code lua>
Line 56: Line 71:
 </​code>​ </​code>​
  
-==== World Object ​====+====世界对象====
  
-The world object reflects the current world (dimension) the container is in.+世界对象是容器当前所在的世界(维度)的映射。
  
 - `getMetadata(x:​number,​ y:number, z:​number):​number`  ​ - `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`  ​ - `getBlockId(x:​number,​ y:number, z:​number):​number`  ​
-  ​Get the ID of the block at the specified coordinates.+  ​获取位于指定坐标的方块的ID。   
 +\\
 - `getDimensionId():​number`  ​ - `getDimensionId():​number`  ​
-  ​Gets the numeric id of the current dimension.+  ​获取当前维度的数字ID。 ​  
 +\\
 - `isLoaded(x:​number,​ y:number, z:​number):​number`  ​ - `isLoaded(x:​number,​ y:number, z:​number):​number`  ​
-  ​Check whether the block at the specified coordinates is loaded.+  ​检查位于指定坐标的方块是否被加载。 ​  
 +\\
 - `getSeed():​number`  ​ - `getSeed():​number`  ​
-  ​Gets the seed of the world.+  ​获取世界的种子。 ​  
 +\\
 - `removeFluid(amount:​number,​ x:number, y:number, z:number, side:​number):​boolean`  ​ - `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`  ​ - `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`  ​ - `getDimensionName():​string`  ​
-  ​Gets the name of the current dimension.+  ​获取当前维度的名称。 ​  
 +\\
 - `getTime():​number`  ​ - `getTime():​number`  ​
-  ​Get the current world time.+  ​获取当前世界时间。 ​  
 +\\
 - `setTime(value:​number)`  ​ - `setTime(value:​number)`  ​
-  ​Set the current world time.+  ​设定当前世界时间。 ​  
 +\\
 - `getLightValue(x:​number,​ y:number, z:​number):​number`  ​ - `getLightValue(x:​number,​ y:number, z:​number):​number`  ​
-  ​Get the light value (emission) of the block at the specified coordinates.+  ​获取位于指定坐标处的方块的光照等级(自身发出的)。 ​  
 +\\
 - `isRaining():​boolean`  ​ - `isRaining():​boolean`  ​
-  ​Returns whether it is currently raining.+  ​返回当前天气是否为降雨。 ​  
 +\\
 - `setRaining(value:​boolean)`  ​ - `setRaining(value:​boolean)`  ​
-  ​Sets whether it is currently raining.+  ​设定当前天气是否为降雨。 ​  
 +\\
 - `isThundering():​boolean`  ​ - `isThundering():​boolean`  ​
-  ​Returns whether it is currently thundering.+  ​返回当前天气是否为雷暴。 ​  
 +\\
 - `setThundering(value:​boolean)`  ​ - `setThundering(value:​boolean)`  ​
-  ​Sets whether it is currently thundering.+  ​设定当前天气是否为雷暴。 ​  
 +\\
 - `setBlock(x:​number,​ y:number, z:number, id:number or string, meta:​number):​number`  ​ - `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`  ​ - `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).+  ​在指定范围内填充指定方块,范围为立方体,由两个对角顶点(x1, y1, z1)(x2, y2, z2)表示。 ​  
 +\\
 - `removeItem(x:​number,​ y:number, z:number, slot:​number[,​ count:​number]):​number`  ​ - `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`  ​ - `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.+  ​将一个物品堆放入到指定坐标处物品容器的指定槽位中。给定的NBT标签需为JSON格式。 ​  
 +\\
 - `getSpawnPoint():​number,​ number, number`  ​ - `getSpawnPoint():​number,​ number, number`  ​
-  ​Get the current spawn point coordinates.+  ​获取当前的重生点坐标。 ​  
 +\\
 - `setSpawnPoint(x:​number,​ y:number, z:​number)`  ​ - `setSpawnPoint(x:​number,​ y:number, z:​number)`  ​
-  ​Set the spawn point coordinates.+  ​设定重生点坐标。 ​  
 +\\
 - `canSeeSky(x:​number,​ y:number, z:​number):​number`  ​ - `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`  ​ - `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`  ​ - `hasTileEntity(x:​number,​ y:number, z:​number):​number`  ​
-  ​Check whether the block at the specified coordinates has a tile entity.+  ​检查位于指定坐标处的方块是否具有方块实体。 ​  
 +\\
 - `playSoundAt(x:​number,​ y:number, z:number, sound:​string,​ range:​number)`  ​ - `playSoundAt(x:​number,​ y:number, z:number, sound:​string,​ range:​number)`  ​
-  ​Play a sound at the specified coordinates.+  ​在指定坐标处播放音效。 ​  
 +\\
 - `getTileNBT(x:​number,​ y:number, z:​number):​table`  ​ - `getTileNBT(x:​number,​ y:number, z:​number):​table`  ​
-  ​Get the NBT of the block at the specified coordinates.+  ​获取位于指定坐标处的方块的NBT数据。 ​  
 +\\
 - `setTileNBT(x:​number,​ y:number, z:number, nbt:​table):​boolean`  ​ - `setTileNBT(x:​number,​ y:number, z:number, nbt:​table):​boolean`  ​
-  ​Set the NBT of the block at the specified coordinates.+  ​设定位于指定坐标处的方块的NBT数据。 ​  
 +\\
 - `getBlockState(x:​number,​ y:number, z:number[, actualState:​boolean=false])`  ​ - `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():​userdata`  ​ - `getWorld():​userdata`  ​
-  ​Get the player'​s world object.+  ​获取玩家所在世界的世界对象。 ​  
 +\\
 - `getGameType():​string`  ​ - `getGameType():​string`  ​
-  ​Get the player'​s game type.+  ​获取玩家的游戏模式。 ​  
 +\\
 - `setGameType(gametype:​string)`  ​ - `setGameType(gametype:​string)`  ​
-  ​Set the player'​s game type (survivalcreativeadventure).+  ​设定玩家的游戏模式(`survival`-生存,`creative`-创造,`adventure`-冒险)。 ​  
 +\\
 - `getHealth():​number`  ​ - `getHealth():​number`  ​
-  ​Get the player'​s health.+  ​获取玩家的生命值。 ​  
 +\\
 - `setHealth(health:​number)`  ​ - `setHealth(health:​number)`  ​
-  ​Set the player'​s health.+  ​设定玩家的生命值。 ​  
 +\\
 - `getMaxHealth():​number`  ​ - `getMaxHealth():​number`  ​
-  ​Get the player'​s max health.+  ​获取玩家的最大生命值。 ​  
 +\\
 - `getPosition():​number,​ number, number`  ​ - `getPosition():​number,​ number, number`  ​
-  ​Get the player'​s position.+  ​获取玩家的位置。 ​  
 +\\
 - `setPosition(x:​number,​ y:number, z:​number)`  ​ - `setPosition(x:​number,​ y:number, z:​number)`  ​
-  ​Set the player'​s position.+  ​设定玩家的位置。 ​  
 +\\
 - `getExperienceTotal():​number`  ​ - `getExperienceTotal():​number`  ​
-  ​Get the player'​s total experience+  ​获取玩家的总经验值。 ​  
 +\\
 - `getLevel():​number`  ​ - `getLevel():​number`  ​
-  ​Get the player'​s level+  ​获取玩家的等级。 ​  
 +\\
 - `addExperienceLevel(level:​number)`  ​ - `addExperienceLevel(level:​number)`  ​
-  ​Add a level to the player'​s experience level+  ​为玩家的经验等级增加一级。 ​  
 +\\
 - `removeExperienceLevel(level:​number)`  ​ - `removeExperienceLevel(level:​number)`  ​
-  Remove a level from the player'​s experience level+   ​为玩家的经验等级减少一级。 ​  
 + \\
 - `insertItem(id:​string,​ amount:​number,​ meta:​number[,​ nbt:​string]):​number`  ​ - `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(objectiveName:​string,​ objectiveCriteria:​string)`  ​ - `addObjective(objectiveName:​string,​ objectiveCriteria:​string)`  ​
-  ​Create a new objective for the scoreboard+  ​在计分板中创建一个新的对象。 ​  
 +\\
 - `removeObjective(objectiveName:​string)`  ​ - `removeObjective(objectiveName:​string)`  ​
-  ​Remove an objective from the scoreboard+  ​从计分板中移除一个对象。 ​  
 +\\
 - `increasePlayerScore(playerName:​string,​ objectiveName:​string,​ score:​int)`  ​ - `increasePlayerScore(playerName:​string,​ objectiveName:​string,​ score:​int)`  ​
-  ​Increases the score of a player for a certain objective+  ​增加某计分板对象中某玩家的分数。 ​  
 +\\
 - `decreasePlayerScore(playerName:​string,​ objectiveName:​string,​ score:​int)`  ​ - `decreasePlayerScore(playerName:​string,​ objectiveName:​string,​ score:​int)`  ​
-  ​Decrease the score of a player for a certain objective+  ​减少某计分板对象中某玩家的分数。 ​  
 +\\
 - `addPlayerToTeam(player:​string,​ team:​string):​boolean`  ​ - `addPlayerToTeam(player:​string,​ team:​string):​boolean`  ​
-  ​Add a player to a team+  ​将某玩家加入某团队中。 ​  
 +\\
 - `removePlayerFromTeam(player:​string,​ team:​string):​boolean`  ​ - `removePlayerFromTeam(player:​string,​ team:​string):​boolean`  ​
-  ​Remove a player from a specific team+  ​将一名玩家从指定团队中移除。 ​  
 +\\
 - `removePlayerFromTeams(player:​string):​boolean`  ​ - `removePlayerFromTeams(player:​string):​boolean`  ​
-  ​Remove a player from their team+  ​将一名玩家从所有团队中移除。 ​  
 +\\
 - `addTeam(team:​string)`  ​ - `addTeam(team:​string)`  ​
-  ​Add a team to the scoreboard+  ​将一个团队添加到计分板中。 ​  
 +\\
 - `removeTeam(teamName:​ string)`  ​ - `removeTeam(teamName:​ string)`  ​
-  ​Remove a team from the scoreboard+  ​从计分板中移除一个团队。 ​  
 +\\
 - `getPlayerScore(playerName:​string,​ objectiveName:​string):​int`  ​ - `getPlayerScore(playerName:​string,​ objectiveName:​string):​int`  ​
-  ​Gets the score of a player for a certain objective+  ​获取某计分板对象中某玩家的分数。 ​  
 +\\
 - `setPlayerScore(playerName:​string,​ objectiveName:​string,​ score:​int)`  ​ - `setPlayerScore(playerName:​string,​ objectiveName:​string,​ score:​int)`  ​
-  ​Sets the score of a player for a certain objective+  ​设定某计分板对象中某玩家的分数。
  
 目录 目录