Posted 30 July 2016 - 03:54 PM
i have a hand scanner program on a server, it has a radar and a monitor. You right click on the monitor and it will say whether you're allowed in or not, but i need an extra pair of eyes to check my programming. i cant find the problem but i'm hoping one of you could see it. Thank you guys.
os.loadAPI("ocs/apis/sensor")
door = peripheral.wrap("monitor_1")
door.setTextScale(0.5)
radar = sensor.wrap("right")
allow = {}
allow.AlexJCamp = true
allow.pedromac002 = false
avoid = {}
avoid.pedromac002 = true
xMin = -5
xMax = -1
yMin = -6
yMax = -4
term.redirect(door)
handGood = paintutils.loadImage("handGood")
handBad = paintutils.loadImage("handBad")
handNormal = paintutils.loadImage("hand")
–paintutils.drawImage(handNormal,1,1)
local function checkInRange(number, min, max)
return number >= min and number <= max
end
local function checkTargets(targets, compare)
for k,v in pairs(compare) do
if targets[k] then
–print(targets[k].Position.X," ", targets[k].Position.Z
–sleep(8)
if checkInRange(targets[k].Position.X, xMin, xMax) then
if checkInRange(targets[k].Position.Z, yMin, yMax) then
return true
end
end
end
end
return false
end
while true do
timer = os.startTimer(1)
e, k = os.pullEvent()
–term.clear()
–print(table.getn(radar.getTargets()))
if checkTargets(radar.getTargets(),allow) or checkTargets(radar.getTargets(),avoid) then
paintutils.drawImage(handNormal, 1,1)
else
term.clear()
end
if e == "monitor_touch" then
if checkTargets(radar.getTargets(),allow) and not checkTargets(radar.getTargets(), avoid) then
paintutils.drawImage(handGood, 1 1)
rs.setOutput("back", true)
sleep(2)
os.reboot()
else
paintutils.drawImage(handBad, 1,1)
sleep(3)
os.reboot()
end
end
end
os.loadAPI("ocs/apis/sensor")
door = peripheral.wrap("monitor_1")
door.setTextScale(0.5)
radar = sensor.wrap("right")
allow = {}
allow.AlexJCamp = true
allow.pedromac002 = false
avoid = {}
avoid.pedromac002 = true
xMin = -5
xMax = -1
yMin = -6
yMax = -4
term.redirect(door)
handGood = paintutils.loadImage("handGood")
handBad = paintutils.loadImage("handBad")
handNormal = paintutils.loadImage("hand")
–paintutils.drawImage(handNormal,1,1)
local function checkInRange(number, min, max)
return number >= min and number <= max
end
local function checkTargets(targets, compare)
for k,v in pairs(compare) do
if targets[k] then
–print(targets[k].Position.X," ", targets[k].Position.Z
–sleep(8)
if checkInRange(targets[k].Position.X, xMin, xMax) then
if checkInRange(targets[k].Position.Z, yMin, yMax) then
return true
end
end
end
end
return false
end
while true do
timer = os.startTimer(1)
e, k = os.pullEvent()
–term.clear()
–print(table.getn(radar.getTargets()))
if checkTargets(radar.getTargets(),allow) or checkTargets(radar.getTargets(),avoid) then
paintutils.drawImage(handNormal, 1,1)
else
term.clear()
end
if e == "monitor_touch" then
if checkTargets(radar.getTargets(),allow) and not checkTargets(radar.getTargets(), avoid) then
paintutils.drawImage(handGood, 1 1)
rs.setOutput("back", true)
sleep(2)
os.reboot()
else
paintutils.drawImage(handBad, 1,1)
sleep(3)
os.reboot()
end
end
end