local mouseIsPressed = false
local initialDownPosition = 5 -- 初始下移像素点为 5
local currentPosition = initialDownPosition
local downPosition = 1
local increasePosition = 8
local decreasePosition = 7
local resetPosition = 5
-- 鼠标按下事件处理函数
function onMouseDown(x, y)
mouseIsPressed = true
end
-- 鼠标抬起事件处理函数
function onMouseUp(x, y)
mouseIsPressed = false
end
-- 按键 6 按下事件处理函数,用于切换开关状态
function onKeyPress6(x, y)
mouseIsPressed = not mouseIsPressed
end
-- 按键 8 按下事件处理函数,增加下移像素点
function onKeyPress8(x, y)
if mouseIsPressed then
downPosition = downPosition + 1
end
end
-- 按键 7 按下事件处理函数,减少下移像素点
function onKeyPress7(x, y)
if mouseIsPressed and downPosition > 0 then
downPosition = downPosition - 1
end
end
-- 按键 5 按下事件处理函数,复位参数
function onKeyPress5(x, y)
mouseIsPressed = false
currentPosition = initialDownPosition -- 复位当前位置为初始下移像素点
end
-- 处理鼠标移动事件
function onMouseMove(x, y)
if mouseIsPressed then
-- 获取当前时间
local startTime = os.clock()
while os.clock() - startTime < 0.001 do -- 延时 1 毫秒
end
-- 以鼠标当前位置为起点,下移一个像素点
currentPosition = x + downPosition, y
end
end