Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
component:debug [2018/03/12 12:23]
kiritow add maunal for new function
component:debug [2018/10/07 03:29] (current)
payonel [Component: Debug]
Line 41: Line 41:
 - `sendToClipboard(player:​string,​ text:​string)`  ​ - `sendToClipboard(player:​string,​ text:​string)`  ​
   Sends text to the specified player'​s clipboard if possible.   Sends text to the specified player'​s clipboard if possible.
 +- `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.
 +
 +<code lua>
 +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))
 +</​code>​
  
 ==== World Object ==== ==== World Object ====