This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
component:debug [2018/10/07 03:24] payonel [Component: Debug] |
component:debug [2020/05/22 21:39] forecaster [Component: Debug] |
||
---|---|---|---|
Line 8: | Line 8: | ||
The debug card's "container" refers to the robot, computer or tablet with a debug card installed in it. | 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. | ||
Callbacks: | Callbacks: | ||
Line 31: | Line 33: | ||
- `isModLoaded(name:string):boolean` | - `isModLoaded(name:string):boolean` | ||
Get whether a mod or API is loaded. | Get whether a mod or API is loaded. | ||
- | - `runCommand(command:string):number` | + | - `runCommand(command:string):number, string` |
- | Runs an arbitrary command using a fake player. | + | 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():userdata` | - `test():userdata` | ||
Test method for user-data and general value conversion. | Test method for user-data and general value conversion. | ||
Line 45: | Line 47: | ||
<code lua> | <code lua> | ||
- | local debug = require("component").debug | + | local debug = require("component").debug |
- | local serialize = require("serialization").serialize | + | local serialize = require("serialization").serialize |
- | local x, y, z = debug.getX, debug.getY, debug.getZ | + | local x, y, z = debug.getX, debug.getY, debug.getZ |
- | local offset_x = -1 | + | local offset_x = -1 |
- | local offset_z = 0 | + | local offset_z = 0 |
- | local blocking, label, content = debug.scanContentsAt(x() - .5 + offset_x, y() - .5, z() - .5 + offset_z) | + | local blocking, label, content = debug.scanContentsAt(x() - .5 + offset_x, y() - .5, z() - .5 + offset_z) |
- | print(blocking, label, serialize(content)) | + | print(blocking, label, serialize(content)) |
</code> | </code> | ||