I am trying to create a local function in Lua (GHUB) to move the mouse to a specific coordiinates on the screen. However the pointer moves suddenly at the end of the function call ... and does not even go to the right position. Also .. is there anyway I can debug Lua ... in GHUB is practically impossible from what I see. Not even syntax errors.
Thank you!
local function MouseMoveToSlower(x, y, speed)
current_x, current_y = GetMousePosition()
distance = math.sqrt((x - current_x)^2 + (y - current_y)^2)
steps = math.floor(distance / speed)
for i = 1, steps do
new_x = current_x + (x - current_x) * i / steps
new_y = current_y + (y - current_y) * i / steps
MoveMouseRelative(new_x - current_x, new_y - current_y)
Sleep(math.random(102,125))
end
end
MoveMouseRelativeexpects distance in1 pixelunits (screen width = 1920 units)GetMousePositionreturns distance in(screen_size)/64Kunits (screen width = 65536 units)You should convert values correctly.