尝试通过Logitech GHub为GMod创建一个Lua脚本来使玩家的视野旋转180度,但无法找到如何进行旋转的方法

这是我目前的代码。我想找到一种更有效的方法,在不需要按住主鼠标按钮的情况下完成旋转。

EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg)
    if IsKeyLockOn("numlock" )then
        repeat
            if IsMouseButtonPressed(1) then
                repeat
                    MoveMouseRelative (40,0)
                    Sleep(1)
                until not IsMouseButtonPressed(1)
            end
        until not IsMouseButtonPressed(3)
    end
end
点赞
用户17106751
用户17106751

正如 Egor 所说的,你应该使用 for 来代替重复函数...

EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg)
    if IsKeyLockOn("numlock" )then
            if IsMouseButtonPressed(1) then
                for i= 1, 60 -- 60 在我记忆中适用于全高清分辨率(您可以适当调整它以便按两次时恢复到完全相同的位置)
                    MoveMouseRelative (127,0)
                    Sleep(1) -- 此处应使用 fastsleep(0.5),在 stackoverflow 上搜索
                end
            end
    end
end
2021-10-29 07:17:34