Camera
The Camera lets you gather information (specifically, distance from nearest block) in your surroundings.
Recipe
NOTE: The stone bricks on top can be any type of stone bricks.
API
Redstone
Since 0.1.4, you can hook up a redstone wire to the camera to get distance data - the energy level reflects the distance (15 - 0-1 blocks away, 14 - 2-3 blocks away, …., 1 - 30-31 blocks away).
OpenComputers/ComputerCraft
Command | Added in | Description | Usage |
distance([x, y]) | 0.1.0 | Calculates the distance of the closest block. | The x and y parameters are optional. |
Robot Camera Upgrade-specific
Command | Added in | Description |
distanceUp([x, y]) | 0.6.4 (broken before then) | Acts as a camera pointed up. |
distanceDown([x, y]) | 0.6.4 (broken before then) | Acts as a camera pointed down. |
NedoComputers
Address | Read | Write |
0x00 | X direction (-32768 - 32767 == -1.0 - 1.0) | X direction |
0x02 | Y direction | Y direction |
0x04 | Distance, measured in 1/64ths of a block. | - |
Examples
ComputerCraft ray caster
local camera = peripheral.wrap("right")
local array = " .,-=+xX#"
local monitor = peripheral.wrap("monitor_0")
local yp = 1
monitor.clear()
monitor.setTextScale(0.5)
monitor.setCursorPos(1,1)
for j = -0.35,0.25,0.025 do
for i = -1,1,0.036 do
local d = camera.distance(i, 0-j)
local a = 1
if d > 0 then a = 2 + (8 - math.min(8, (d/1.2))) end
monitor.write(string.sub(array, a, a))
end
yp=yp+1
monitor.setCursorPos(1,yp)
end