diff --git a/tests/checkerpick.lua b/tests/checkerpick.lua index 8bbca73..e94352d 100644 --- a/tests/checkerpick.lua +++ b/tests/checkerpick.lua @@ -11,16 +11,14 @@ function init_event() end function mouse_motion_event(x, y, xrel, yrel) - objects = ag.pickObjects(x, y) - for i, obj in ipairs(objects) do - if obj == ground then - x = obj.pick_pos[1] - y = obj.pick_pos[2] - xp = 2 * math.floor(x / 2) + 1 - yp = 2 * math.floor(y / 2) + 1 - if xp >= -3 and xp <= 3 and yp >= -3 and yp <= 3 then - hilite:setPosition(xp, yp, 0.1) - end + local hit = ag.pickOne(x, y, ground) + if hit then + x = ground.pick_pos[1] + y = ground.pick_pos[2] + xp = 2 * math.floor(x / 2) + 1 + yp = 2 * math.floor(y / 2) + 1 + if xp >= -3 and xp <= 3 and yp >= -3 and yp <= 3 then + hilite:setPosition(xp, yp, 0.1) end end end