I love this mod but I encountered a bug. When I run my program once it works normally, but the second time I run it, it breaks everything and I have to reboot the PC to make it work again.
Using version 0.1. In 0.12 pre 1 the sensorview program doesn't work and sensors are very buggy so I decided to stay on 0.1.
This is the code:
-- Init:
os.loadAPI("ocs/apis/sensor")
local player = {...}
local side = {"top", "bottom", "front", "back", "left", "right"}
if #player < 1 then
print("Usage: monplayerdbg <player name>")
return
end
for i=1, 6 do
if peripheral.getType(side[i]) == "sensor" then
sensor = sensor.wrap(side[i])
if sensor.getSensorName() == nil then
textutils.slowWrite("No sensor card detected! \n") sleep(0.5)
return
end
if string.sub(sensor.getSensorName(), 20) == "proximitysensor" then
prox = sensor.wrap(side[i])
elseif sensor.getSensorName ~= nil then
textutils.slowWrite("Invalid sensor card detected! \n")
sleep(0.5)
return
end
end
if peripheral.getType(side[i]) == "monitor" then
mon = peripheral.wrap(side[i])
end
end
-- Functions:
function monUpdate(name, x, y, z)
mon.clear()
mon.setCursorPos(1, 1)
mon.write(name..":")
mon.setCursorPos(1, 2)
mon.write("X: "..x)
mon.setCursorPos(1, 3)
mon.write("Y: "..y)
mon.setCursorPos(1, 4)
mon.write("Z: "..z)
end
function refresh()
targets = sensor.getTargets()
term.clear()
term.setCursorPos(1, 1)
end
-- Code:
while true do
refresh()
for n, i in pairs(targets) do
if i.type == "Player" then
if n == tostring(player[1]) then
--print(n.." "..tostring(i.Position.X).." "..tostring(i.Position.Y).." "..tostring(i.Position.Z))
--rs.setOutput("left", isInArea(n, i.Position.X, i.Position.Y, i.Position.Z))
monUpdate(n, i.Position.X, i.Position.Y, i.Position.Z)
end
end
end
end
Tried running the sensorview program after running this one and it breaks it when I select the side the sensor is on and outputs "attempt to call nil" at line 63. I assume it breaks the whole sensor to variable assignment as in my program it points to line 14 which is "sensor = sensor.wrap(side[i])". I'd really like that this gets fixed.














