罗技lua随机延迟实现
_RPG_
编辑于 2023年07月29日 18:01
收录于文集
共3篇

主要实现是 match.random(a,b)

function OnEvent(event, arg)

    --OutputLogMessage("Event: &#​34;..event.." Arg: &#​34;..arg.."\n&#​34;)

    if (event == "MOUSE_BUTTON_PRESSED&#​34; and arg == 5) then

        bool = not bool

        OutputLogMessage("bool= %s \n  &#​34;, bool)

    end

    if (event == "MOUSE_BUTTON_PRESSED&#​34; and IsKeyLockOn("capslock&#​34;)) then

        OutputLogMessage("OPENKEY= %s \n  &#​34;, IsKeyLockOn("capslock&#​34;))

        if(  bool ) then

          repeat

              --random1

              random1 = math.random(0, 100)

              --random2

              random2 = math.random(0, 100)

              --核心执行

              Sleep(random1)

              PressAndReleaseKey("1&#​34;)

              Sleep(random2)

              OutputLogMessage("random1=%s\n random2=%s\n &#​34;, random1, random2)

          until not IsKeyLockOn("capslock&#​34;)

          bool =false

          OutputLogMessage("bool = %s \n  &#​34;, bool)

        end

    end

    if (event == "MOUSE_BUTTON_PRESSED&#​34; and not IsKeyLockOn("capslock&#​34;) and bool ==false ) then

        OutputLogMessage("CLOSE= %s \n  &#​34;, IsKeyLockOn("capslock&#​34;))

    end

end