• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

Quick Question for repeat lua command (1 Viewer)

Xnochz

Newcomer
Joined
Dec 1, 2021
Messages
1
Reaction score
0
Hello guys, im new in lua and need some help with a script.
Lua:
do
   local function busyloop(final_ctr)
      final_ctr = final_ctr - final_ctr%1
      local ctr, prev_ms, ms0, ctr0 = 0
      while ctr ~= final_ctr do
         local ms = GetRunningTime()
         if prev_ms and ms ~= prev_ms then
            if not ms0 then
               ms0, ctr0 = ms, ctr
            elseif final_ctr < 0 and ms - ms0 > 500 then
               return (ctr - ctr0) / (ms - ms0)
            end
         end
         prev_ms = ms
         ctr = ctr + 1
      end
   end
   local coefficient = busyloop(-1)
   function FastSleep(ms)
      return busyloop(ms * coefficient)
   end
end

EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
    if IsKeyLockOn("numlock")then
        if IsMouseButtonPressed(3) then
            repeat
                if IsMouseButtonPressed(1) then
                    repeat
                        MoveMouseRelative(0,1)
                        FastSleep(2,7)
                    until not IsMouseButtonPressed(1)
                end
            until not IsMouseButtonPressed(3)
        end
    end
end

This is a simple mouse movedown script for my presentation at school.

Its possible to do this macro again in itself with command g_pressed 4 but mit FastSleep (8.2)?

Sorry my english isnt that good.

I want to switch between FastSleep 2,7 and FastSleep 8.2 without edit the script.
 
Top