diff options
Diffstat (limited to 'hole.lua')
-rw-r--r-- | hole.lua | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -9,14 +9,28 @@ local scanner = assert(peripheral.wrap"right") local laser = assert(peripheral.wrap"left") while true do - local targets = {} local scanned = scanner.scan() - for _,v in ipairs(scanned) do + local targets = {} + for _,s in ipairs(scanned) do + local should_add = true + for i,t in ipairs(targets) do + if t.x == s.x and t.z == s.z then + should_add = false + if s.y > t.y then + targets[i] = s + end + end + end + if should_add then + table.insert(targets,s) + end + end + for _,v in ipairs(targets) do if v.z <= 7 and v.z >= -8 and v.x <= 7 and v.x >= -8 and v.y < 0 then - local yaw,pitch = yaw_pitch(t.x,t.y,t.z) + local yaw,pitch = yaw_pitch(v.x,v.y,v.z) laser.fire(yaw,pitch,4) end end -until #targets == 0 +end |